38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import json
|
|
from pathlib import Path
|
|
|
|
import falcon
|
|
from falcon_multipart.middleware import MultipartMiddleware
|
|
|
|
from .tools import JsonRequest, JsonResponse, error_handler
|
|
from .controllers import *
|
|
|
|
class AboutResource():
|
|
|
|
def on_get(self, req, resp):
|
|
r = {"about": {
|
|
"name": "echo360py API",
|
|
"version": "1",
|
|
"docs": "TODO"
|
|
}
|
|
}
|
|
resp.body = json.dumps(r, indent=4)
|
|
|
|
|
|
app = application = falcon.API(middleware=[MultipartMiddleware()],
|
|
request_type=JsonRequest,
|
|
response_type=JsonResponse)
|
|
app.add_error_handler(ValueError, error_handler)
|
|
app.add_route("/", AboutResource())
|
|
|
|
app.add_route("/Task", TaskResource())
|
|
app.add_route("/Tasks", TasksCollection())
|
|
app.add_route("/Tasks/{TaskId}", TasksCollection())
|
|
|
|
app.add_route("/Videos/{VideoUuid}/Streams/{StreamId}", StreamCollection())
|
|
|
|
FilesStoragePath = Path("files")
|
|
FilesStoragePath.mkdir(parents=True, exist_ok=True)
|
|
app.add_route("/Files/{FileId}", FileCollection(FilesStoragePath))
|
|
app.add_route("/Files", FileCollection(FilesStoragePath))
|