echo360py/echo360/__init__.py

34 lines
938 B
Python

import json
from pathlib import Path
import falcon
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(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("/File/{FileId}", FileCollection(FilesStoragePath))