Skip to content

samarth3301/flask-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Boilerplate

A simple backend boilerplate for building APIs, designed for rapid development using Python and Flask.

Repository: samarth3301/flask-boilerplate


Features

  • Flask-based structure for API development
  • Simple, minimal, and easy to extend
  • Designed for use with uv Python package manager for fast dependency management

Getting Started

Prerequisites

  • Python 3.8+
  • uv (modern Python package manager, recommended over pip)

Installation

  1. Clone the Repository

    git clone https://github.com/samarth3301/flask-boilerplate.git
    cd flask-boilerplate
  2. 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 .

Running the Application

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.


Routes

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 main app.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.


Development & Customization

  • Add more endpoints by creating new routes.
  • Update requirements.txt and install new dependencies using uv pip install <package>.
  • Use .env for environment variables.

Useful Commands

  • Install dependencies:
    uv pip install -r requirements.txt
  • Add new dependencies:
    uv pip install <package>
  • Freeze dependencies:
    uv pip freeze > requirements.txt

License

This project is licensed under the MIT License. See LICENSE for details.


Happy coding!

About

a simple backend boilerplate for building APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages