bugfix:
This commit is contained in:
parent
d93ec2b0f3
commit
59d4f098ea
|
|
@ -0,0 +1,35 @@
|
||||||
|
[[source]]
|
||||||
|
url = "http://mirrors.cloud.aliyuncs.com/pypi/simple/"
|
||||||
|
verify_ssl = false
|
||||||
|
name = "pip_conf_index_global"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
aiofiles = "==22.1.0"
|
||||||
|
aioredis = "==2.0.1"
|
||||||
|
aiomysql = "==0.1.1"
|
||||||
|
bcrypt = "==4.0.1"
|
||||||
|
email-validator = ">=2.0.0"
|
||||||
|
fastapi = "==0.111.0"
|
||||||
|
fastapi-plugins = "==0.13.0"
|
||||||
|
fastapi-sqlalchemy = "==0.2.1"
|
||||||
|
pydantic = ">=2.0.0"
|
||||||
|
pydantic-settings = "==2.2.1"
|
||||||
|
python-multipart = ">=0.0.7"
|
||||||
|
pytest = "==7.2.1"
|
||||||
|
requests = "==2.28.2"
|
||||||
|
sqlacodegen = "==2.3.0"
|
||||||
|
sqlalchemy = "==2.0.1"
|
||||||
|
uvicorn = "==0.20.0"
|
||||||
|
pyjwt = "==2.6.0"
|
||||||
|
passlib = "==1.7.4"
|
||||||
|
pillow = "==9.4.0"
|
||||||
|
captcha = "==0.4"
|
||||||
|
jinja2 = "==3.1.2"
|
||||||
|
pycryptodome = "==3.17"
|
||||||
|
qiniu = "==7.10.0"
|
||||||
|
pytz = "==2022.7.1"
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.10"
|
||||||
|
|
@ -11,8 +11,10 @@ database=test
|
||||||
|
|
||||||
|
|
||||||
[redis]
|
[redis]
|
||||||
|
redis_url=""
|
||||||
redis_host=redis
|
redis_host=redis
|
||||||
redis_port=6379
|
redis_port=6379
|
||||||
|
redis_password=""
|
||||||
|
|
||||||
[rabbitmq]
|
[rabbitmq]
|
||||||
rabbitmq_host=rabbitmq
|
rabbitmq_host=rabbitmq
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@ database=test
|
||||||
|
|
||||||
|
|
||||||
[redis]
|
[redis]
|
||||||
|
redis_url=""
|
||||||
redis_host=redis
|
redis_host=redis
|
||||||
redis_port=6379
|
redis_port=6379
|
||||||
|
redis_password=""
|
||||||
|
|
||||||
[rabbitmq]
|
[rabbitmq]
|
||||||
rabbitmq_host=rabbitmq
|
rabbitmq_host=rabbitmq
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ from configparser import ConfigParser
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from fastapi_plugins import RedisSettings
|
from fastapi_plugins import RedisSettings
|
||||||
from pydantic import BaseSettings
|
from pydantic_settings import BaseSettings
|
||||||
|
|
||||||
|
|
||||||
class ReConfigParser(ConfigParser):
|
class ReConfigParser(ConfigParser):
|
||||||
|
|
|
||||||
6
main.py
6
main.py
|
|
@ -29,10 +29,10 @@ def create_app():
|
||||||
mysql_config, redis_config = init_config()
|
mysql_config, redis_config = init_config()
|
||||||
# 添加sqlalchemy数据库中间件
|
# 添加sqlalchemy数据库中间件
|
||||||
# once the middleware is applied, any route can then access the database session from the global ``db``
|
# once the middleware is applied, any route can then access the database session from the global ``db``
|
||||||
app.add_middleware(DBSessionMiddleware, db_url=mysql_config.sqlalchemy_db_uri)
|
# app.add_middleware(DBSessionMiddleware, db_url=mysql_config.sqlalchemy_db_uri)
|
||||||
# Redis 缓存初始化
|
# Redis 缓存初始化
|
||||||
await fastapi_plugins.redis_plugin.init_app(app, redis_config)
|
# await fastapi_plugins.redis_plugin.init_app(app, redis_config)
|
||||||
await fastapi_plugins.redis_plugin.init()
|
# await fastapi_plugins.redis_plugin.init()
|
||||||
|
|
||||||
@app.on_event("shutdown")
|
@app.on_event("shutdown")
|
||||||
async def shutdown_event():
|
async def shutdown_event():
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,12 @@ aiofiles==22.1.0
|
||||||
aioredis==2.0.1
|
aioredis==2.0.1
|
||||||
aiomysql==0.1.1
|
aiomysql==0.1.1
|
||||||
bcrypt==4.0.1
|
bcrypt==4.0.1
|
||||||
email-validator==1.3.1
|
email_validator>=2.0.0
|
||||||
fastapi==0.111.0
|
fastapi==0.111.0
|
||||||
fastapi-plugins==0.11.0
|
fastapi-plugins==0.13.0
|
||||||
FastAPI-SQLAlchemy==0.2.1
|
FastAPI-SQLAlchemy==0.2.1
|
||||||
pydantic==1.10.4
|
pydantic>=2.0.0
|
||||||
|
pydantic-settings==2.2.1
|
||||||
# pydantic-sqlalchemy==0.0.9
|
# pydantic-sqlalchemy==0.0.9
|
||||||
python-multipart>=0.0.7
|
python-multipart>=0.0.7
|
||||||
pytest==7.2.1
|
pytest==7.2.1
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,9 @@ class SendCaptchaSuccess(BaseResponse):
|
||||||
|
|
||||||
|
|
||||||
class BadRequestError(ErrorModel):
|
class BadRequestError(ErrorModel):
|
||||||
code = 400
|
code: int = 400
|
||||||
message = "BAD REQUEST"
|
message: str = "BAD REQUEST"
|
||||||
details = "请求参数错误"
|
details: str = "请求参数错误"
|
||||||
|
|
||||||
|
|
||||||
class BadRequestResponse(BaseResponse):
|
class BadRequestResponse(BaseResponse):
|
||||||
|
|
@ -62,9 +62,9 @@ class BadRequestResponse(BaseResponse):
|
||||||
|
|
||||||
|
|
||||||
class ServerInternalError(ErrorModel):
|
class ServerInternalError(ErrorModel):
|
||||||
code = 500
|
code: int = 500
|
||||||
message = "INTERNAL SERVER ERROR"
|
message: str = "INTERNAL SERVER ERROR"
|
||||||
details = "服务器内部错误"
|
details: str = "服务器内部错误"
|
||||||
|
|
||||||
|
|
||||||
class ServerInternalResponse(BaseResponse):
|
class ServerInternalResponse(BaseResponse):
|
||||||
Loading…
Reference in New Issue