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.0.tar.gz (48.3 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.0-py3-none-any.whl (61.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: misty_zouwu-0.3.0.tar.gz
  • Upload date:
  • Size: 48.3 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.0.tar.gz
Algorithm Hash digest
SHA256 aa8c524c4a2e55a2031a81839ddce34f9741028ffab79eabbd937514a82a9205
MD5 48af0b58641bf1d9668d6101e042fcb5
BLAKE2b-256 1526727fdf1d519a0a9203550658c04b1a906e8d12d32f420d2301347e9aabbd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: misty_zouwu-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8353bbe9af495568cd69d08dd0144f385c2cbfbd0d9426b1c69db04c5fd772f5
MD5 a00e1396b8c4917df2f2c4c8740e637f
BLAKE2b-256 314cda961cf8ed6a6215a7aa86540787f41aadd6b5f22821fddcb32a6c42f952

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