This is a simple Flask app that demonstrates how to create a web application with SQLite database integration. The app allows users to add their first name and last name, which gets stored in an SQLite database.
-
Clone the repository:
git clone https://github.com/your-username/flask-sqlite-example.git
-
Navigate to the project directory:
cd flask-sqlite-example
-
(Optional) Create a virtual environment:
python -m venv venv
Activate the virtual environment:
-
On Windows:
.\venv\Scripts\activate
-
On macOS/Linux:
source venv/bin/activate
-
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the Flask app:
python app.py
The app will be accessible at http://127.0.0.1:5000/ in your web browser.
-
Create a Docker image:
docker build -t flask-sqlite-example . -
Run the Docker container:
docker run -p 5000:5000 flask-sqlite-example
The app will be accessible at http://127.0.0.1:5000/ in your web browser.
-
(Optional) Install DB Browser for SQLite.
-
Open
database.dbin thesrcdirectory using DB Browser for SQLite to visualize the data.
src: Contains the Flask application code.__pycache__: Auto-generated directory for Python bytecode.
static: Contains static files (CSS, images, scripts).images: Place for your images.scripts: JavaScript files.style: CSS files.
templates: HTML templates for the Flask app.
Feel free to explore and modify the code to understand how the Flask app works. If you have any questions or run into issues, don't hesitate to ask.
Happy coding!