-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
40 lines (25 loc) · 1.39 KB
/
main.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
from fastapi import FastAPI, Request, Depends
from streaming import stream
from fastapi.responses import HTMLResponse, StreamingResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
@app.get('/myvideo_feed')
async def video_feed():
# Video streaming route. Put this in the src attribute of an img tag
return StreamingResponse(stream.gen_frames('object'), media_type="multipart/x-mixed-replace; boundary=frame")
@app.get('/video_feed_emotion')
async def video_feed_emotion():
# Video streaming route. Put this in the src attribute of an img tag
return StreamingResponse(stream.gen_frames('emotion'), media_type="multipart/x-mixed-replace; boundary=frame")
@app.get("/object-detection/", response_class=HTMLResponse)
async def home_page(request: Request):
return templates.TemplateResponse("object_detection.html", {"request": request, "dtype": "object"})
@app.get("/emotion/", response_class=HTMLResponse)
async def home_page(request: Request):
return templates.TemplateResponse("object_detection.html", {"request": request, "dtype": "emotion"})
@app.get("/", response_class=HTMLResponse)
async def home_page(request: Request):
return templates.TemplateResponse("index.html", {"request": request})