Skip to main content

驺吾其形似虎,身具五彩斑纹,尾长过身,骑乘可日行千里,且不食活物。集成FastAPI、SQLModel 实现标准CRUD 操作API

Project description

Misty.zouwu (驺吾)

由 Misty(迷雾工作室) 开发的驺吾平台搭建的一套基于FastAPI 的快速搭建的包。

架构

API:FastAPI
Auth: JWT 
ORM: SQLModel
DB: Mysql

依赖包清单

asgi_correlation_id==4.3.4
asgiref==3.11.1
cryptography==46.0.5
fastapi==0.135.1
httpx==0.28.1
itsdangerous==2.2.0
loguru==0.7.3
msgspec==0.20.0
passlib==1.7.4
pydantic==2.12.5
pydantic_core==2.42.0
pydantic_settings==2.13.1
python-dotenv==1.2.2
setuptools==82.0.0
setuptools==80.10.2
SQLAlchemy==2.0.47
sqlmodel==0.0.37
starlette==0.52.1
user_agents==2.2.0
uvicorn==0.41.0
xdbsearchip==1.0.2
redis==7.2.1
pyrate-limiter==4.0.2
fastapi_limiter==0.2.0

配置文件(.env):

#系统配置
SYS_DEBUG = False
SYS_APP_ENV = 'dev'
# 时区和时间格式
SYS_DATETIME_TIMEZONE= 'Asia/Shanghai'
SYS_DATETIME_FORMAT= "%Y-%m-%d %H:%M:%S"
# Profiling
SYS_SLOW_REQUEST_THRESHOLD = 0.1  # 慢请求阈值(秒)
SYS_MEMORY_WARNING_THRESHOLD: = 100 * 1024 * 1024  # 内存警告阈值(字节)

#API配置
API_DEBUG = False
API_PROJECT_NAME = "驺吾API"
API_PROJECT_VERSION = "2.1.0.0302"
API_DESCRIPTION = "由 Misty(迷雾工作室) 开发的驺吾平台搭建的一套ERP管理系统后台服务"
API_PATH = '/api'

# API 地址
API_HOST = '0.0.0.0'
API_PORT = 9900

# Middleware
MIDDLEWARE_CORS = True
MIDDLEWARE_ACCESS = True

# CORS
CORS_ALLOWED_ORIGINS = ['http://localhost:5173','*']

# 加密密钥
# Env Opera Log # 密钥 os.urandom(32), 需使用 bytes.hex(os.urandom(32)) 方法转换为 str
OPERA_LOG_ENCRYPT_SECRET_KEY = 'Misty.zouwu@key'

# Token
TOKEN_SECRET_KEY = '密钥'
TOKEN_ALGORITHM = 'HS256'  # 算法
TOKEN_EXPIRE_SECONDS = 60 * 60 * 24 * 1  # 过期时间,单位:秒
TOKEN_REFRESH_EXPIRE_SECONDS = 60 * 60 * 24 * 7  # refresh token 过期时间,单位:秒

LOG_STDOUT_FILENAME = 'misty_code_access.log'
LOG_STDERR_FILENAME = 'misty_code_error.log'

#数据库配置
DB_DEBUG=False
DB_TYPE='MySql'
DB_HOST='localhost'
DB_PORT=13306
DB_DATABASE='zouwu'
DB_USERNAME='misty_zuowu'
DB_PASSWORD='misty.zouwu'

Demo(main.py)

from dotenv import load_dotenv

load_dotenv()

from apis.api_register import register_app, start_app

if __name__ == '__main__':
    routers = []
    app = register_app(routers)
    start_app(app)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

misty_zouwu-0.3.1.tar.gz (48.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

misty_zouwu-0.3.1-py3-none-any.whl (61.3 kB view details)

Uploaded Python 3

File details

Details for the file misty_zouwu-0.3.1.tar.gz.

File metadata

  • Download URL: misty_zouwu-0.3.1.tar.gz
  • Upload date:
  • Size: 48.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for misty_zouwu-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e668461544ed540268948212d458a4c4453b63f834e55017515e7cd83bd8b05c
MD5 2edf5a9e08c34f3a3bf1b44baf36378d
BLAKE2b-256 ed3095af88045738cd35527257e46a8e818499485f3ea2f82536f93ed17701b1

See more details on using hashes here.

File details

Details for the file misty_zouwu-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: misty_zouwu-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 61.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for misty_zouwu-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d909cc49218d79e860398878a9b3e193b26f214d3f9889bdfdcddffbd717ff0
MD5 654e98ed661f20ef3c7bab62e25bd270
BLAKE2b-256 988641e934316de06ad32d9efa388f91f29d3ba6b2b2fb4b4d566d0485b15ff3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page