This commit is contained in:
wuaho 2021-06-02 21:46:59 +08:00
parent 7d17b62fc9
commit 5665a45c6d
2 changed files with 12 additions and 59 deletions

View File

@ -12,56 +12,9 @@ from utils import *
router = APIRouter()
#
# @router.post("/channel.json")
# async def channel.json(
# data_in: schemas.BaleCreate
# ) -> schemas.Msg:
# file = os.path.join(settings.ROOT_DIR, 'ApkTool/channel.json')
# with open(file, 'w') as f:
# json.dump(data_in.channel.json, f)
#
# resp = schemas.Msg(
# code=0,
# msg='ok',
# data=data_in
# )
#
# return resp
# @router.post("/keystore")
# async def keystore(
# file: bytes = File(...)
# ) -> schemas.Msg:
# file_path = os.path.join(settings.ROOT_DIR, 'ApkTool/keystore/legu.keystore')
# with open(file_path, 'wb') as f:
# f.write(file)
#
# resp = schemas.Msg(
# code=0,
# msg='ok',
# data=file_path
# )
#
# return resp
#
#
# @router.post("/mother_bag")
# async def mother_bag(
# file: UploadFile = File(...)
# ) -> schemas.Msg:
# file_path = os.path.join(settings.ROOT_DIR, f'ApkTool/{file.filename}')
# with open(file_path, 'wb') as f:
# for i in iter(lambda: file.file.read(1024 * 1024 * 10), b''):
# f.write(i)
#
# resp = schemas.Msg(
# code=0,
# msg='ok',
# data=file_path
# )
# return resp
@router.get("/test")
async def test():
1 / 0
@router.post("/upload_file")

18
main.py
View File

@ -2,7 +2,7 @@
import uvicorn
from fastapi import FastAPI
from fastapi.exceptions import RequestValidationError
from fastapi import Response
from starlette.responses import Response
from starlette.middleware.cors import CORSMiddleware
import schemas
@ -21,14 +21,14 @@ app.add_middleware(
)
# @app.exception_handler(RequestValidationError)
# async def validation_exception_handler(request, exc):
# return Response(schemas.Msg(code='-1', msg='服务器错误', data=str(exc)), status_code=200)
#
#
# @app.exception_handler(Exception)
# async def http_exception_handler(request, exc):
# return Response(schemas.Msg(code='-1', msg='服务器错误'), status_code=200)
@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):
return Response(schemas.Msg(code=-1, msg='服务器错误', data=str(exc)).json(), status_code=200)
@app.exception_handler(Exception)
async def http_exception_handler(request, exc):
return Response(schemas.Msg(code=-1, msg='服务器错误', data=str(exc)).json(), status_code=200)
if __name__ == '__main__':