-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
50 lines (37 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
47
48
49
50
"""
Simple app to create Trick Play - Mode from/for HLS m3u8.
"""
# Built-in
# Special
from flask import Flask, jsonify, make_response
from flask_restful import Api
# App
from api.event import post_event
from api.log_listener import setup_log_event_handlers
from routes.system_info_endpoint import SystemInfoEndpoint
from routes.trick_play_endpoint import TrickPlayEndpoint
setup_log_event_handlers()
app = Flask(__name__)
api = Api(app)
## API Routes
api.add_resource(SystemInfoEndpoint, "/api/systemInfo")
api.add_resource(TrickPlayEndpoint, "/api/trickPlay/hls")
## Error handling
@app.errorhandler(404)
def resource_not_found(e):
func = f"{__name__}.resource_not_found"
post_event(
"log_exception",
f"{func}",
f"{e}",
)
message = {"success": False, "message": f"{e}"}
response = make_response(
jsonify(message),
404,
)
response.headers["Content-Type"] = "application/json"
return response
## Setting up the app
if __name__ == "__main__":
app.run()