-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
46 lines (35 loc) · 1.02 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import uvicorn
from fastapi import FastAPI
from fastapi import Body
from fastapi.middleware.cors import CORSMiddleware
import model
from fastapi import Request
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
app = FastAPI()
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
templates = Jinja2Templates(directory="public")
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.get('/')
async def index(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
# @app.get('/')
# def get_name():
# return {'Welcome': 'Hello World,its siraj'}
@app.post('/predict')
def predict_Anime(data: str = Body(...)):
prediction = model.predict(data)
return {
'prediction': prediction,
}
if __name__ == '__main__':
uvicorn.run(app, host='127.0.0.1', port=5000)
#run in terminal
# uvicorn app:app --reload