mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-20 08:11:50 +08:00
23 lines
622 B
Python
23 lines
622 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from fastapi import APIRouter, File, Form, UploadFile
|
|
|
|
from backend.app.tasks import task_demo_async
|
|
|
|
router = APIRouter(prefix='/tests')
|
|
|
|
|
|
@router.post('/send', summary='测试异步任务')
|
|
async def task_send():
|
|
result = task_demo_async.delay()
|
|
return {'msg': 'Success', 'data': result.id}
|
|
|
|
|
|
@router.post('/files', summary='测试文件上传')
|
|
async def create_file(file: bytes = File(), fileb: UploadFile = File(), token: str = Form()):
|
|
return {
|
|
'file_size': len(file),
|
|
'token': token,
|
|
'fileb_content_type': fileb.content_type,
|
|
}
|