v0.1 fastapi: route + model + orm

This commit is contained in:
geeker
2026-09-19 10:41:18 +08:00
commit f4fa2f9714
55 changed files with 3615 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
from typing import Annotated
from fastapi import Depends, FastAPI,APIRouter,Form,File,UploadFile
from fastapi.security import OAuth2PasswordRequestForm
route = APIRouter(prefix="/file",tags=["file"])
@route.post("/bytes")
def bytes(file:bytes = File()):
print("bytes:\t" + str(file))
print("str:\t" + file.decode("utf-8"))
return file.decode("utf-8")
@route.post("/uploadfile")
async def uploadfile(file:UploadFile):
data = await file.read()
print("bytes:\t" + str(data))
print("str:\t" + data.decode("utf-8"))
return data.decode("utf-8")
# text read/write