Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -32,22 +32,16 @@ class FileToProcess(BaseModel):
|
|
32 |
async def home():
|
33 |
return "API Working!"
|
34 |
|
35 |
-
@app.post("/
|
36 |
#async def upload_file(username: str, file_to_process: FileToProcess = Depends()):
|
37 |
-
async def
|
38 |
uploaded_file = file_to_process.uploaded_file
|
39 |
print("File received:"+uploaded_file.filename)
|
40 |
-
print("File received:", uploaded_file.filename)
|
41 |
-
print("File received: " + str(uploaded_file.filename))
|
42 |
|
43 |
username = request.query_params.get("username")
|
44 |
filename = request.query_params.get("filename")
|
45 |
print(username)
|
46 |
-
print(filename)
|
47 |
-
|
48 |
-
#print("File received:"+file_to_process.filename)
|
49 |
-
#`file_to_process`是`FileToProcess`类的一个实例,它具有一个名为`uploaded_file`的属性,而不是`filename`属性。
|
50 |
-
#因此,在打印`"File received:"+file_to_process.filename`时会引发`AttributeError`。
|
51 |
|
52 |
random_string = generate_random_string(20)
|
53 |
file_path = Path.cwd() / random_string
|
@@ -77,12 +71,10 @@ async def upload_file(username: str, request: Request, file_to_process: FileToPr
|
|
77 |
print(temp_texts)
|
78 |
print()
|
79 |
|
80 |
-
#api_call_msg={"INFO": f"File '{uploaded_file.filename}' saved to your profile."}
|
81 |
api_call_msg={"INFO": f"File '{file_saved_in_api}' saved to your profile."}
|
82 |
print(api_call_msg)
|
83 |
|
84 |
print(api_call_msg["INFO"])
|
85 |
-
#File 'uploaded_file' saved to your profile.
|
86 |
print()
|
87 |
print(api_call_msg["INFO"].replace("uploaded_file", uploaded_file.filename))
|
88 |
|
|
|
32 |
async def home():
|
33 |
return "API Working!"
|
34 |
|
35 |
+
@app.post("/fastapi_file_upload_process")
|
36 |
#async def upload_file(username: str, file_to_process: FileToProcess = Depends()):
|
37 |
+
async def pdf_file_qa_process(username: str, request: Request, file_to_process: FileToProcess = Depends()):
|
38 |
uploaded_file = file_to_process.uploaded_file
|
39 |
print("File received:"+uploaded_file.filename)
|
|
|
|
|
40 |
|
41 |
username = request.query_params.get("username")
|
42 |
filename = request.query_params.get("filename")
|
43 |
print(username)
|
44 |
+
print(filename)
|
|
|
|
|
|
|
|
|
45 |
|
46 |
random_string = generate_random_string(20)
|
47 |
file_path = Path.cwd() / random_string
|
|
|
71 |
print(temp_texts)
|
72 |
print()
|
73 |
|
|
|
74 |
api_call_msg={"INFO": f"File '{file_saved_in_api}' saved to your profile."}
|
75 |
print(api_call_msg)
|
76 |
|
77 |
print(api_call_msg["INFO"])
|
|
|
78 |
print()
|
79 |
print(api_call_msg["INFO"].replace("uploaded_file", uploaded_file.filename))
|
80 |
|