peterhartwigCF commited on
Commit
38a4b70
·
verified ·
1 Parent(s): 42bc87e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,7 +1,28 @@
1
- from fastapi import FastAPI
 
2
 
 
 
3
  app = FastAPI()
4
 
5
  @app.get("/")
6
  def greet_json():
7
  return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, File, UploadFile
2
+ import logging
3
 
4
+ logger = logging.getLogger('uvicorn.error')
5
+ logger.setLevel(logging.DEBUG)
6
  app = FastAPI()
7
 
8
  @app.get("/")
9
  def greet_json():
10
  return {"Hello": "World!"}
11
+
12
+
13
+ @app.get("/makeVersions")
14
+ def make_versions():
15
+ return("making versions")
16
+
17
+ @app.post("/upload/")
18
+ async def upload_file(file: UploadFile = File(...)):
19
+ content = await file.read()
20
+
21
+ # Print information about the file to the console
22
+ logger.debug(f"File Name: {file.filename}")
23
+ logger.debug(f"File Size: {len(content)}")
24
+ logger.debug(f"File MIME Type: {file.content_type}")
25
+
26
+ # Return information about the file to the caller - note that the
27
+ # content_type can easily be spoofed
28
+ return {"filename": file.filename, "file_size": len(content), "file_mime_type": file.content_type}