-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Closed
Labels
Description
Example
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import FileResponse
from pydantic import BaseModel
import numpy as np
import shutil
app = FastAPI()
@app.get("/")
async def main():
return FileResponse(r"misdo.jpg")
@app.post("/uploadfile/")
async def create_upload_file(image: UploadFile = File(...)):
with open("destination.jpg", "wb") as buffer:
shutil.copyfileobj(image.file, buffer)
return image.filename`Description
-
This code is work fine in 127.0.0.1:8000/docs.
-
But I am wondering how can I post without using 127.0.0.1:8000/docs.
-
More specified is how could I use other languague(Swift) to interact with this API.
-
I know how to do with HTTP.GET, but HTTP.POST still bothering me.
-
Or is my POST funtion is not well defined?
Environment
- macOS
- FastAPI Version: 0.61.1
- Python version: 3.8.6