Spaces:
Sleeping
Sleeping
Commit
•
96d2b4f
1
Parent(s):
af0cbd9
Update main.py
Browse files
main.py
CHANGED
@@ -1,28 +1,13 @@
|
|
1 |
from fastapi import FastAPI, Query, Request
|
2 |
from fastapi.responses import JSONResponse, HTMLResponse
|
3 |
-
from transformers import pipeline
|
4 |
-
import subprocess
|
5 |
-
import httpx
|
6 |
-
|
7 |
-
from transformers import pipeline
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
11 |
-
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
12 |
|
13 |
@app.get("/infer_t5")
|
14 |
def t5(input):
|
15 |
-
output
|
16 |
-
return {"output": output[0]["generated_text"]}
|
17 |
|
18 |
@app.get("/", response_class=HTMLResponse)
|
19 |
async def streamlit_proxy(request: Request):
|
20 |
-
|
21 |
-
streamlit_url = "http://localhost:8501/"
|
22 |
-
response = await client.get(streamlit_url)
|
23 |
-
return HTMLResponse(content=response.text, status_code=response.status_code)
|
24 |
-
|
25 |
-
@app.on_event("startup")
|
26 |
-
async def startup_event():
|
27 |
-
# Запуск Streamlit в отдельном процессе
|
28 |
-
subprocess.Popen(["streamlit", "run", "streamlit_app.py"])
|
|
|
1 |
from fastapi import FastAPI, Query, Request
|
2 |
from fastapi.responses import JSONResponse, HTMLResponse
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
|
|
6 |
|
7 |
@app.get("/infer_t5")
|
8 |
def t5(input):
|
9 |
+
return {"output": "output"}
|
|
|
10 |
|
11 |
@app.get("/", response_class=HTMLResponse)
|
12 |
async def streamlit_proxy(request: Request):
|
13 |
+
return 'Server is running'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|