A web application that helps users learn React.js concepts through interactive exercises and code examples.
-
Clone the repository:
git clone git@github.com:JupyterJones/reactjs-learning-assistant.git cd reactjs-learning-assistant
-
Set up the backend:
cd backend python3 -m venv venv source venv/bin/activate which python # Verify you're using the virtual environment's Python python -m pip install -r requirements.txt
-
Set up environment variables (if needed):
-
Create a
.env
file in thebackend/
directory. -
Example
.env
(replace with your actual values):DATABASE_URL=sqlite:///./mydatabase.db API_KEY=YOUR_API_KEY
-
-
Set up the frontend:
cd ../frontend npm install
You'll need two terminal windows to run the backend and frontend simultaneously.
-
Navigate to the backend directory:
cd backend
-
Make the
Start
script executable (this script likely runs the Flask development server):chmod +x Start
-
Run the backend:
./Start
- The
Start
script starts the Flask development server onhttp://localhost:8000
.
- The
-
Navigate to the frontend directory:
cd frontend
-
Start the React development server:
npm start
- This will usually open the application in your browser at
http://localhost:3000
.
- This will usually open the application in your browser at
This Python script (NOTE
) is a command-line tool designed for interacting with a simple notes database (stored in an SQLite file named notes.db
). It provides functionality to manage notes directly from the terminal.
The script allows users to perform the following operations:
- Create: Initialize the notes database.
- Insert: Add new notes to the database.
- Read: Display existing notes from the database.
- Search: Find notes containing specific text within the database.
- Delete: Remove notes from the database using their unique ID.
- Print: Export notes to a text file.
- Help: Display usage instructions.
-
Imports and Setup
import sys
: Enables access to command-line arguments.import sqlite3
: Provides tools for interacting with SQLite databases.from datetime import datetime
: Imports thedatetime
class for timestamping notes.conn = sqlite3.connect("notes.db")
: Establishes a connection to thenotes.db
SQLite database file.conn.text_factory = str
: Configures SQLite to handle text data as Python strings.c = conn.cursor()
: Creates a cursor object for executing SQL queries.
-
Argument Handling
- The script validates the number of command-line arguments. If fewer than 3 are provided, it displays a help message and exits.
mod = sys.argv[1]
: Stores the first command-line argument (e.g.,-I
,-R
,-D
) to determine the operation to be performed.
-
Functions
create()
:- Creates the
PROJECT
table innotes.db
using the Full-Text Search (FTS4) module. - Returns the message "Database Created".
- Creates the
insert(data, conn=conn, c=c)
:- Inserts a new note (
data
) into thePROJECT
table, including a timestamp. - Prints confirmation of the insertion with the note's ID.
- Inserts a new note (
search(data, conn=conn, c=c)
:- Searches for notes containing the specified text (
data
). - Prints the ID and content of matching notes.
- Searches for notes containing the specified text (
delete(rowid, conn=conn, c=c)
:- Deletes the note with the given
rowid
(row ID). - Returns a deletion confirmation message.
- Deletes the note with the given
main()
:- Retrieves all notes from the
PROJECT
table. - Prints each note's ID and content.
- Retrieves all notes from the
prtmain(filename)
:- Exports all notes to a text file (
filename
), formatting each note with its ID and separating notes with "----".
- Exports all notes to a text file (
HELP()
:- Displays detailed usage instructions for the script.
-
Main Execution Block
- The script uses
if
statements to execute the appropriate function based on the value of themod
argument. - Example:
if mod == "-H" or mod == "h": HELP()
if mod == "-I" or mod == "-i": insert(sys.argv[2])
- If an unrecognized
mod
argument is provided, a generic "Command Completed" message is printed.
- The script uses
(As provided by the HELP()
output)
python NOTE -I "Buy groceries"
: Adds a new note.python NOTE -D 3
: Deletes the note with ID 3.python NOTE -R .
: Displays all notes.python NOTE -S "current project"
: Searches for notes containing "current project".python NOTE -T mynotes.txt
: Saves all notes to a file namedmynotes.txt
.python NOTE -H .
: Shows the help message.