aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex <alexta69@gmail.com>2023-02-18 01:37:43 +0200
committerGitHub <noreply@github.com>2023-02-18 01:37:43 +0200
commitd1e679c2744ed2d2f453456b9a12061057119684 (patch)
tree247d01d84268d0211f426b0dba30c410e7247797 /app
parentMerge pull request #219 from PikuZheng/patch-1 (diff)
parentMerge branch 'master' into master (diff)
downloadmetube-d1e679c2744ed2d2f453456b9a12061057119684.tar.gz
metube-d1e679c2744ed2d2f453456b9a12061057119684.tar.bz2
metube-d1e679c2744ed2d2f453456b9a12061057119684.zip
Merge pull request #172 from unref/master
Added a couple env variables
Diffstat (limited to 'app')
-rw-r--r--app/main.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/main.py b/app/main.py
index 46f4424..6fc46c6 100644
--- a/app/main.py
+++ b/app/main.py
@@ -24,6 +24,9 @@ class Config:
'OUTPUT_TEMPLATE': '%(title)s.%(ext)s',
'OUTPUT_TEMPLATE_CHAPTER': '%(title)s - %(section_number)s %(section_title)s.%(ext)s',
'YTDL_OPTIONS': '{}',
+ 'HOST': '0.0.0.0',
+ 'PORT': '8081',
+ 'BASE_DIR': ''
}
_BOOLEAN = ('CUSTOM_DIRS', 'CREATE_CUSTOM_DIRS')
@@ -144,7 +147,7 @@ def get_custom_dirs():
@routes.get(config.URL_PREFIX)
def index(request):
- return web.FileResponse('ui/dist/metube/index.html')
+ return web.FileResponse(os.path.join(config.BASE_DIR, 'ui/dist/metube/index.html'))
if config.URL_PREFIX != '/':
@routes.get('/')
@@ -155,10 +158,10 @@ if config.URL_PREFIX != '/':
def index_redirect_dir(request):
return web.HTTPFound(config.URL_PREFIX)
-routes.static(config.URL_PREFIX + 'favicon/', 'favicon')
+routes.static(config.URL_PREFIX + 'favicon/', os.path.join(config.BASE_DIR, 'favicon'))
routes.static(config.URL_PREFIX + 'download/', config.DOWNLOAD_DIR)
routes.static(config.URL_PREFIX + 'audio_download/', config.AUDIO_DOWNLOAD_DIR)
-routes.static(config.URL_PREFIX, 'ui/dist/metube')
+routes.static(config.URL_PREFIX, os.path.join(config.BASE_DIR, 'ui/dist/metube'))
try:
app.add_routes(routes)
except ValueError as e:
@@ -166,8 +169,6 @@ except ValueError as e:
raise RuntimeError('Could not find the frontend UI static assets. Please run `node_modules/.bin/ng build` inside the ui folder') from e
raise e
-
-
# https://github.com/aio-libs/aiohttp/pull/4615 waiting for release
# @routes.options(config.URL_PREFIX + 'add')
async def add_cors(request):
@@ -186,4 +187,4 @@ app.on_response_prepare.append(on_prepare)
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
- web.run_app(app, port=8081)
+ web.run_app(app, host=config.HOST, port=config.PORT, reuse_port=True)
bgstack15