diff --git a/frontends/ycdl_flask/ycdl_flask_launch.py b/frontends/ycdl_flask/ycdl_flask_dev.py similarity index 87% rename from frontends/ycdl_flask/ycdl_flask_launch.py rename to frontends/ycdl_flask/ycdl_flask_dev.py index c0aa19f..327fedb 100644 --- a/frontends/ycdl_flask/ycdl_flask_launch.py +++ b/frontends/ycdl_flask/ycdl_flask_dev.py @@ -2,7 +2,7 @@ This file is the gevent launcher for local / development use. Simply run it on the command line: -python ycdl_flask_launch.py [port] +python ycdl_flask_dev.py [port] ''' import gevent.monkey; gevent.monkey.patch_all() @@ -22,7 +22,11 @@ from voussoirkit import pathclass import bot import ycdl -import ycdl_flask_entrypoint +import backend + +#################################################################################################### + +site = backend.site HTTPS_DIR = pathclass.Path(__file__).parent.with_child('https') @@ -33,21 +37,21 @@ def ycdl_flask_launch(create, port, refresh_rate, use_https): if use_https: http = gevent.pywsgi.WSGIServer( listener=('0.0.0.0', port), - application=ycdl_flask_entrypoint.site, + application=site, keyfile=HTTPS_DIR.with_child('ycdl.key').absolute_path, certfile=HTTPS_DIR.with_child('ycdl.crt').absolute_path, ) else: http = gevent.pywsgi.WSGIServer( listener=('0.0.0.0', port), - application=ycdl_flask_entrypoint.site, + application=site, ) youtube_core = ycdl.ytapi.Youtube(bot.get_youtube_key()) - ycdl_flask_entrypoint.backend.common.init_ycdldb(youtube_core, create=create) + backend.common.init_ycdldb(youtube_core, create=create) if refresh_rate is not None: - ycdl_flask_entrypoint.backend.common.start_refresher_thread(refresh_rate) + backend.common.start_refresher_thread(refresh_rate) message = f'Starting server on port {port}' if use_https: diff --git a/frontends/ycdl_flask/ycdl_flask_entrypoint.py b/frontends/ycdl_flask/ycdl_flask_entrypoint.py deleted file mode 100644 index 4a634e0..0000000 --- a/frontends/ycdl_flask/ycdl_flask_entrypoint.py +++ /dev/null @@ -1,13 +0,0 @@ -''' -This file is the WSGI entrypoint for remote / production use. - -If you are using Gunicorn, for example: -gunicorn ycdl_flask_entrypoint:site --bind "0.0.0.0:PORT" --access-logfile "-" -''' -import werkzeug.middleware.proxy_fix - -import backend - -backend.site.wsgi_app = werkzeug.middleware.proxy_fix.ProxyFix(backend.site.wsgi_app) - -site = backend.site diff --git a/frontends/ycdl_flask/ycdl_flask_prod.py b/frontends/ycdl_flask/ycdl_flask_prod.py new file mode 100644 index 0000000..f3ed401 --- /dev/null +++ b/frontends/ycdl_flask/ycdl_flask_prod.py @@ -0,0 +1,21 @@ +''' +This file is the WSGI entrypoint for remote / production use. + +If you are using Gunicorn, for example: +gunicorn ycdl_flask_prod:site --bind "0.0.0.0:PORT" --access-logfile "-" +''' +import werkzeug.middleware.proxy_fix + +import bot +import ycdl + +import backend + +backend.site.wsgi_app = werkzeug.middleware.proxy_fix.ProxyFix(backend.site.wsgi_app) + +site = backend.site + +# NOTE: Consider adding a local .json config file. +youtube_core = ycdl.ytapi.Youtube(bot.get_youtube_key()) +backend.common.init_ycdldb(youtube_core, create=False) +backend.common.start_refresher_thread(86400)