Giter Club home page Giter Club logo

py-template-fastapi-bed's Introduction

Python FastAPI Template

中文文档请查看 README_zh.md

Basic Features

  • Basic framework
  • Switchable environment configurations
  • Automatic code reloading
  • SQLAlchemy-based ORM
  • Swagger API documentation support
  • Logging using the logure framework
  • JWT authentication
  • RUFF code standards
  • One-line command to generate CRUD templates including model, schema, and router
  • Complete CI/CD workflow and production environment Docker-compose automatic deployment template
  • Using RUFF to standardize code

Getting Started

1. Install Poetry

pip install poetry

2. Install Dependencies

poetry install

3. Start Development

poetry run app

4. Switch Environments

poetry run app env=dev  # Development environment (default)
poetry run app env=prod # Production environment

In dev environment, the development server will automatically reload the code

Generate CRUD Templates (Automatically appends model creation and router inclusion) RECOMMENDED

! Note: After automatic appending, if you need to undo it, please manually delete the appended code. Do not use Ctrl+Z in the IDE, as it may cause code formatting issues.

1. Execute the following command

poetry run create_crud name={data_model_name} -a  # Use `_` as a separator for multi-word names, case-insensitive

For example:

poetry run create_crud name=example -a

Generate CRUD Templates (Manually add model creation and router inclusion)

1. Execute the following command

poetry run create_crud name={data_model_name} -a  # Use `_` as a separator for multi-word names, case-insensitive

For example:

poetry run create_crud name=example

2. Add automatic table creation

In src/models/__init__.py, import your associated models under # $table_create$:

# $table_create$ 自动创建表追加锚 *请不要修改此行* (Anchor of the table creation line *Do not modify this line*)
from .{data_model_name} import DB{DataModelClassName}

3. Mount the router

In src/app.py, under Mount the router tables, add the router:

from src.routers.{data_model_name} import router as {data_model_name}_router

app.include_router({data_model_name}_router, prefix="/{router_prefix}", tags=["{router_tag}"])

Please replace {data_model_name}, {DataModelClassName}, {router_prefix}, and {router_tag} with the appropriate values as needed for your project.

py-template-fastapi-bed's People

Contributors

kromiose avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.