File size: 1,344 Bytes
12e4bed
 
 
6ccc851
63bf853
 
 
 
 
 
 
 
12e4bed
 
 
6ccc851
 
f40115c
eefdb3e
 
 
f40115c
 
 
eefdb3e
 
f40115c
 
 
 
 
 
6ccc851
12e4bed
 
63bf853
 
 
 
 
 
12e4bed
 
 
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
import aiohttp_cors
from aiohttp import web

#---------------------- Local Imports --------------------#
#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


#-----------------------------Functions------------------------#
#CORS is only configured to Handle V2
async def handle_v2(request):
    return web.Response(text="Hello from app api!")

#---------------------------Routes ---------------------------#
# Web server setup with optimized CORS handling
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)