Spaces:
Sleeping
Sleeping
dinhquangson
commited on
Commit
•
22aa66a
1
Parent(s):
fde2b19
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from fastapi import FastAPI, UploadFile, File
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
# Loading
|
4 |
import os
|
@@ -132,6 +132,19 @@ def search(prompt: str):
|
|
132 |
for hit in hits:
|
133 |
print(hit.payload, "score:", hit.score)
|
134 |
return hits
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
@app.get("/")
|
137 |
def api_home():
|
|
|
1 |
+
from fastapi import FastAPI, UploadFile, File, FileResponse
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
# Loading
|
4 |
import os
|
|
|
132 |
for hit in hits:
|
133 |
print(hit.payload, "score:", hit.score)
|
134 |
return hits
|
135 |
+
|
136 |
+
@app.get("/download-database/")
|
137 |
+
async def download_database():
|
138 |
+
# Path to the database directory
|
139 |
+
database_dir = join(os.getcwd(), 'database')
|
140 |
+
# Path for the zip file
|
141 |
+
zip_path = join(os.getcwd(), 'database.zip')
|
142 |
+
|
143 |
+
# Create a zip file of the database directory
|
144 |
+
shutil.make_archive(zip_path.replace('.zip', ''), 'zip', database_dir)
|
145 |
+
|
146 |
+
# Return the zip file as a response for download
|
147 |
+
return FileResponse(zip_path, media_type='application/zip', filename='database.zip')
|
148 |
|
149 |
@app.get("/")
|
150 |
def api_home():
|