Purpose: This is the default template that I wrote to setup basic functionality for my python websites.
This is a simple Python web application built using the Flask framework. It includes basic functionality for user registration, login, and logout, all backed by a SQLite database. The application is styled using CSS and is designed to be easy to deploy and run, either locally or within a Docker container.
- User Registration: Users can create an account by providing their first name, last name, email, username, and password.
- User Login/Logout: Registered users can log in and log out securely.
- Responsive Design: The application is styled with responsive CSS, ensuring it looks good on various devices.
This is the main application file. It defines the Flask app and sets up routes for registration, login, logout, and the homepage. The application also handles database interactions and user authentication.
This is the base HTML template that contains the overall structure of the webpage, including the navigation menu, content blocks, and footer. Other HTML files extend this template.
This HTML template extends base.html
and provides the layout for the login page. Users can enter their username and password here to log in.
This HTML template extends base.html
and provides the layout for the registration page. Users can enter their details here to create a new account.
This CSS file contains the base styling for the entire application, including body styles, navigation menu styles, and footer styles.
This CSS file contains specific styles for the login and registration pages, such as form layout and input field styling.
This file specifies the files and directories that should be ignored by Git. Typically, this includes files like __pycache__
, *.pyc
, environment variables, and the SQLite database file.
This file contains configuration settings for the Flask application, including the SECRET_KEY
for sessions and SQLALCHEMY_DATABASE_URI
for the database connection.
This file contains the instructions to build a Docker image for the application. It installs all the necessary dependencies and sets up the environment to run the Flask app within a Docker container.
- Python 3.x
- Flask
- Flask-Login
- Flask-SQLAlchemy
- Werkzeug
- Waitress
- Docker (optional, for containerized deployment)
-
Clone the repository:
git clone https://github.com/yourusername/your-repo-name.git cd your-repo-name
-
Set up a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up the database: The database will be automatically created when you first run the application.
-
Run the application:
python main.py
-
Access the application: Open your browser and navigate to
http://127.0.0.1:5003
to see the application in action.
-
Build the Docker image:
docker build -t flask-app .
-
Run the Docker container:
docker run -d -p 5003:5003 flask-app
-
Access the application: Open your browser and navigate to
http://localhost:5003
to see the application running inside the Docker container.
The config.py
file is used to manage sensitive information like the SECRET_KEY
and SQLALCHEMY_DATABASE_URI
. Ensure this file is properly configured before deploying the application.
- Security: Make sure to keep your
SECRET_KEY
secure and never expose it in your version control. - Database: The application uses SQLite by default, which is suitable for development and small-scale deployment. For production, consider switching to a more robust database like PostgreSQL or MySQL.
- Scaling: If you need to scale this application, consider deploying it on a cloud platform like AWS, Azure, or Google Cloud, and using a managed database service.