diff --git a/.gitignore b/.gitignore index e5b3e50..4b247bf 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,9 @@ node_modules/ # Javascript .next next-env.d.ts + +# Gradle files +.gradle/ +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ diff --git a/python/fastapi-helloworld/src/hello_api/my_app.py b/python/fastapi-helloworld/src/hello_api/my_app.py index 2a26878..63c3cdb 100644 --- a/python/fastapi-helloworld/src/hello_api/my_app.py +++ b/python/fastapi-helloworld/src/hello_api/my_app.py @@ -1,7 +1,23 @@ -from fastapi import FastAPI +from fastapi import FastAPI, UploadFile, File app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"} + + +@app.post("/upload/") +async def upload_file(file: UploadFile = File(...)): + # Read metadata + filename = file.filename + content_type = file.content_type + + # Read the actual contents (async) + contents = await file.read() + + return { + "filename": filename, + "content_type": content_type, + "file_size_bytes": len(contents) + }