Does anyone have a code for me so that I can upload a file and work with the file e.g. can call os from the tmp folder?
My code up to now gives some http erros:
from typing import List
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import HTMLResponse
app = FastAPI()
@app.post("/import_file")
async def import_file_post(file: UploadFile = File(...)):
return {"filename": file.filename}
@app.get("/")
async def main():
content = """
<label for="myfile">Select a file:</label>
<form action="/import_file/" enctype="multipart/form-data" method="post">
<input name="files" type="file">
<input type="submit">
</form>
"""
Thank you!
I have tryed it with some blocks of the doc but it actually doesnt work at me :(