Files
Wu Clan a22aaa0a3e Attempt to optimize serialization performance (#266)
* Attempt to serialize performance optimization

* Add casbin service functions return type

* update comments
2024-01-11 20:15:03 +08:00

32 lines
872 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import Annotated
from fastapi import APIRouter, File, Form, UploadFile
from backend.app.common.response.response_schema import ResponseModel, response_base
from backend.app.tasks import task_demo_async
router = APIRouter(prefix='/tests')
@router.post('/send', summary='异步任务演示')
async def send_task() -> ResponseModel:
result = task_demo_async.delay()
return await response_base.success(data=result.id)
@router.post('/files', summary='上传文件演示')
async def create_file(
file: Annotated[bytes, File()],
fileb: Annotated[UploadFile, File()],
token: Annotated[str, Form()],
) -> ResponseModel:
return ResponseModel(
data={
'file_size': len(file),
'token': token,
'fileb_content_type': fileb.content_type,
}
)