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 = APIRouter()
# @router.get("/test")
# @router.post("/channel.json") async def test():
# async def channel.json( 1 / 0
# 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.post("/upload_file") @router.post("/upload_file")

18
main.py
View File

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