kareem2222
commited on
Commit
•
f94e225
1
Parent(s):
f0d8e40
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,12 @@
|
|
1 |
from fastapi import FastAPI, UploadFile, HTTPException
|
2 |
-
import os
|
3 |
import subprocess
|
4 |
-
import
|
5 |
-
import uvicorn
|
6 |
-
|
7 |
-
# تثبيت المكتبات المطلوبة
|
8 |
-
subprocess.check_call(["pip", "install", "nest_asyncio"])
|
9 |
-
subprocess.check_call(["pip", "install", "pydub"])
|
10 |
|
11 |
app = FastAPI()
|
12 |
|
|
|
|
|
|
|
13 |
@app.post("/ask-question/")
|
14 |
async def ask_question(file: UploadFile):
|
15 |
try:
|
@@ -32,9 +29,12 @@ async def ask_question(file: UploadFile):
|
|
32 |
except Exception as e:
|
33 |
raise HTTPException(status_code=500, detail=str(e))
|
34 |
|
|
|
|
|
|
|
35 |
if __name__ == "__main__":
|
36 |
# Apply the patch
|
37 |
nest_asyncio.apply()
|
38 |
|
39 |
-
# Run the FastAPI app
|
40 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
1 |
from fastapi import FastAPI, UploadFile, HTTPException
|
|
|
2 |
import subprocess
|
3 |
+
import os
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
7 |
+
# تثبيت المكتبات عند بدء التشغيل
|
8 |
+
subprocess.check_call(["pip", "install", "-r", "requirements.txt"])
|
9 |
+
|
10 |
@app.post("/ask-question/")
|
11 |
async def ask_question(file: UploadFile):
|
12 |
try:
|
|
|
29 |
except Exception as e:
|
30 |
raise HTTPException(status_code=500, detail=str(e))
|
31 |
|
32 |
+
import nest_asyncio
|
33 |
+
import uvicorn
|
34 |
+
|
35 |
if __name__ == "__main__":
|
36 |
# Apply the patch
|
37 |
nest_asyncio.apply()
|
38 |
|
39 |
+
# Run the FastAPI app
|
40 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|