A Flask-based application for tracking movies, featuring user registration, login, and a comprehensive movie tracker.
Follow these instructions to set up and run the application on your local machine.
- Python 3.13 or higher
- Virtual environment (
venv
) - Flask and required dependencies (as specified in
requirements.txt
) - MySQL
To get started, clone the repository to your local machine using the following command:
git clone https://github.com/nehalp13/CapstoneProject.git
cd CapstoneProject/capstone
Run the movies_db.sql
script in your MySQL environment to create the database structure:
- To run the entire script, look for the lightning bolt icon (⚡) in the toolbar
- Open the
Project.ipynb
Jupyter Notebook file and execute each cell to insert data into the newly created database. - Before running the notebooks, update the database connection string in each notebook to reflect your username and password:
engine = create_engine('mysql+mysqlconnector://username:password@localhost/movies_db')
- For example, if your credentials are as follows:
engine = create_engine('mysql+mysqlconnector://root:Root%40123@localhost/movies_db')
Make sure to change the username and password according to your MySQL credentials.
-
Create and Activate a Virtual Environment:
- On macOS/Linux:
python3 -m venv venv source venv/bin/activate
- On Windows:
python -m venv venv .\venv\Scripts\activate
- On macOS/Linux:
-
Install Dependencies: Install the required Python packages:
pip install -r requirements.txt
-
Configure Database Connection:
- Open
config.py
andapp/__init__.py
, and set your database connection string:# MySQL connection string SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://username:password@localhost/movies_db'
- Ensure that the connection string in
app/__init__.py
matches what you set inconfig.py
.
- Open
-
Generate a Random Secret Key: Run the following command in the terminal to generate a random secret key:
python secret.py
The output will be a random secret key (a byte string) to use in your Flask application.
-
Set the Secret Key in Your Flask App:
- On macOS/Linux:
export SECRET_KEY="your_generated_secret_key" # Replace with the output from secret.py
- On Windows:
To set it permanently:
set SECRET_KEY="your_generated_secret_key" # For current session
setx SECRET_KEY "your_generated_secret_key"
- On macOS/Linux:
-
Set Environment Variables:
- On macOS/Linux:
export FLASK_APP=run.py export FLASK_DEBUG=1
- On Windows:
set FLASK_APP=run.py set FLASK_DEBUG=1
- On macOS/Linux:
-
Start the Flask Development Server:
flask run
If port 5000 is already in use, specify an alternative port:
flask run --port 5001
-
Access the Application: Open your browser and navigate to http://127.0.0.1:5000 to view the application.
- Register for an account if you’re a new user.
- Login with your credentials to access and update your movie tracker.
- Add, delete, or update movie status as you track your movie-watching progress.
- User Registration and Login with password validation.
- Movie Tracker: Add movies to monitor their completion status.
- Custom Error Handling for:
- Duplicate movie entries.
- Attempting to update a movie not present in the tracker.
- InvalidCredentialsError: Raised if the login credentials are incorrect, displaying an error message on the login page.
- UsernameAlreadyExistsError: Raised during registration if a user tries to register with a taken username.
- ValueError: Raised if the password does not meet regex validation requirements.
- Ensure that your database credentials are correct and update them in the necessary files.
- Don't forget to set and export the secret key before running the Flask app.
- Update
username
andpassword
with your actual MySQL credentials in all Python notebooks inProject.ipynb
, as well as in the Flask app files such asconfig.py
andapp/__init__.py
. - Replace
your_generated_secret_key
with the key obtained after runningsecret.py
and export it accordingly.