A simple backend boilerplate for building APIs, designed for rapid development using Python and Flask.
Repository: samarth3301/flask-boilerplate
- Flask-based structure for API development
- Simple, minimal, and easy to extend
- Designed for use with uv Python package manager for fast dependency management
- Python 3.8+
- uv (modern Python package manager, recommended over pip)
-
Clone the Repository
git clone https://github.com/samarth3301/flask-boilerplate.git cd flask-boilerplate
-
Install Dependencies with
uv
Initialize your environment and install dependencies:
uv venv .venv source .venv/bin/activate # On Windows use: .venv\Scripts\activate uv pip install -r requirements.txt
Note: If you have a
pyproject.toml
, use:uv pip install .
Start the Flask development server:
flask run
Or, if you have an app.py
or similar entrypoint:
python app.py
By default, the server runs at http://localhost:5000.
This boilerplate is structured to make it easy to add new API routes. Here’s how routes are typically handled:
-
All routes are defined in the
routes/
directory or in the mainapp.py
file. -
Example of a basic route in
app.py
:from flask import Flask, jsonify app = Flask(__name__) @app.route("/") def home(): return jsonify({"message": "Welcome to Flask Boilerplate!"})
-
To add new routes, create new Python files in the
routes/
directory (if it exists) and import them in your main app.
Tip: For modular APIs, use Blueprints to organize your routes.
- Add more endpoints by creating new routes.
- Update
requirements.txt
and install new dependencies usinguv pip install <package>
. - Use
.env
for environment variables.
- Install dependencies:
uv pip install -r requirements.txt
- Add new dependencies:
uv pip install <package>
- Freeze dependencies:
uv pip freeze > requirements.txt
This project is licensed under the MIT License. See LICENSE for details.
Happy coding!