mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-30 17:50:39 -05:00
* 🌐 Refactor file structure to support internationalization * ✅ Update tests changed after i18n * 🔀 Merge Typer style from master * 🔧 Update MkConfig with Typer-styles * 🎨 Format mkdocs.yml with cannonical form * 🎨 Format mkdocs.yml * 🔧 Update MkDocs config * ➕ Add docs translation scripts dependencies * ✨ Add Typer scripts to handle translations * ✨ Add missing translation snippet to include * ✨ Update contributing docs, add docs for translations * 🙈 Add docs_build to gitignore * 🔧 Update scripts with new locations and docs scripts * 👷 Update docs deploy action with translations * 📝 Add note about languages not supported in the theme * ✨ Add first translation, for Spanish
34 lines
826 B
Python
34 lines
826 B
Python
from typing import List
|
|
|
|
from fastapi import FastAPI, File, UploadFile
|
|
from fastapi.responses import HTMLResponse
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.post("/files/")
|
|
async def create_files(files: List[bytes] = File(...)):
|
|
return {"file_sizes": [len(file) for file in files]}
|
|
|
|
|
|
@app.post("/uploadfiles/")
|
|
async def create_upload_files(files: List[UploadFile] = File(...)):
|
|
return {"filenames": [file.filename for file in files]}
|
|
|
|
|
|
@app.get("/")
|
|
async def main():
|
|
content = """
|
|
<body>
|
|
<form action="/files/" enctype="multipart/form-data" method="post">
|
|
<input name="files" type="file" multiple>
|
|
<input type="submit">
|
|
</form>
|
|
<form action="/uploadfiles/" enctype="multipart/form-data" method="post">
|
|
<input name="files" type="file" multiple>
|
|
<input type="submit">
|
|
</form>
|
|
</body>
|
|
"""
|
|
return HTMLResponse(content=content)
|