-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (26 loc) · 802 Bytes
/
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
import logging
from threading import Thread
from flask import Response, app, Flask
from flask_cors import CORS
from objects.Camera import Camera
from objects.Config import Config
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
config = Config("config.ini")
camera = Camera(config.camera_stream_link(), config.camera_refresh_rate())
app = Flask(__name__)
CORS(app)
@app.route("/stream")
def stream():
return Response(camera.read(), mimetype='multipart/x-mixed-replace; boundary=frame')
def run_api():
from waitress import serve
serve(app, host="0.0.0.0", port=8080)
if __name__ == "__main__":
thread = Thread(target=run_api)
thread.daemon = True
thread.start()
while True:
pass