Katpeeler commited on
Commit
a6c6c8e
1 Parent(s): b548392

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -2
main.py CHANGED
@@ -1,8 +1,20 @@
1
  from fastapi import FastAPI
 
 
2
 
 
3
 
4
  app = FastAPI()
5
 
 
 
 
 
 
 
 
 
 
6
  @app.get("/")
7
- def read_root():
8
- return {"Hello": "World!"}
 
1
  from fastapi import FastAPI
2
+ from fastapi.staticfiles import StaticFiles
3
+ from fastapi.responses import FileResponse
4
 
5
+ from transformers import pipeline
6
 
7
  app = FastAPI()
8
 
9
+ pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
10
+
11
+ @app.get("/infer_t5")
12
+ def t5(input):
13
+ output = pipe_flan(input)
14
+ return {"output": output[0]["generated_text"]}
15
+
16
+ app.mount("/", StaticFiles(directory="static", html=True), name="static")
17
+
18
  @app.get("/")
19
+ def index() -> FileResponse:
20
+ return FileResponse(path="/app/static/index.html", media_type="text/html")