|
import aiohttp_cors |
|
from aiohttp import web |
|
|
|
|
|
from .listings import ( |
|
list_all_files_db, |
|
list_all_files, |
|
list_all_files_tmdb, |
|
list_10_all_files_db, |
|
list_all_tmdb_tv_from_db, |
|
list_all_tmdb_movies_from_db, |
|
) |
|
from .downloads import stream_handler |
|
from .uploads import upload_file |
|
|
|
async def handle_v2(request): |
|
return web.Response(text="Hello from app api!") |
|
|
|
|
|
api = web.Application() |
|
cors = aiohttp_cors.setup(api, defaults={"*": aiohttp_cors.ResourceOptions( |
|
allow_credentials=False, |
|
expose_headers="*", |
|
allow_headers="*", |
|
allow_methods="*" |
|
)}) |
|
|
|
cors.add(api.router.add_get('/', handle_v2)) |
|
|
|
api.router.add_get('/files', list_all_files_db) |
|
api.router.add_get('/files/mix', list_all_files) |
|
api.router.add_get('/tmdb/mix', list_all_files_tmdb) |
|
api.router.add_get('/10/files', list_10_all_files_db) |
|
api.router.add_get('/tmdb/tv', list_all_tmdb_tv_from_db) |
|
api.router.add_get('/tmdb/movies', list_all_tmdb_movies_from_db) |
|
|
|
api.router.add_get('/upload', upload_file) |
|
api.router.add_get('/dl/{path}', stream_handler) |
|
|