-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
67 lines (55 loc) · 1.48 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""APP
FastAPI app definition, initialization and definition of routes
"""
# # Installed # #
from imp import reload
from dotenv import load_dotenv
# from Slr import Prediction
from fastapi import FastAPI, WebSocket
from gesdec_api.routers import model,feedback
from gesdec_api.db import init_db
from fastapi.middleware.cors import CORSMiddleware
origins = [
"http://localhost:3000/",
]
# # Package # #
from gesdec_api.settings import api_settings
load_dotenv()
init_db()
app = FastAPI(
tags=['Model'],
title="Gesture-Detection api"
)
# @app.websocket("/ws")
# async def websocket_endpoint(websocket: WebSocket):
# await websocket.accept()
# prediction=Prediction()
# while True:
# data = await websocket.receive_json()
# res=prediction.predict(data["keypoints"])
# if(res!=None):
# print(res)
# await websocket.send_json(res)
# # print(base64.b64decode(data))
# # print("hi")
app.include_router(model.router)
app.include_router(feedback.router)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# def run():
# """Run the API using Uvicorn"""
# uvicorn.run(
# 'app:app',
# port=api_settings.port,
# host=api_settings.host,
# reload=True,
# )
if __name__=="__main__":
print("running")
# run()
# uvicorn.run('app:app', host='localhost', port=8000,reload=True)