desktop support
This commit is contained in:
@@ -1,10 +1,24 @@
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import flask
|
||||
import redis
|
||||
|
||||
app = flask.Flask("seagull-game", root_path="/app")
|
||||
log = logging.getLogger()
|
||||
pipe_stderr = logging.StreamHandler(sys.stderr)
|
||||
pipe_stderr.setLevel(logging.DEBUG)
|
||||
log.addHandler(pipe_stderr)
|
||||
|
||||
if getattr(sys, "frozen", False):
|
||||
path_appdir = pathlib.Path(sys._MEIPASS)
|
||||
else:
|
||||
path_appdir = pathlib.Path.cwd()
|
||||
log.critical(path_appdir)
|
||||
|
||||
desktop_mode = False
|
||||
|
||||
app = flask.Flask("seagull-game", root_path=path_appdir)
|
||||
orig_url_for = app.url_for
|
||||
|
||||
#REDIS_HOST="stub-implementation.example.net"
|
||||
@@ -16,9 +30,8 @@ orig_url_for = app.url_for
|
||||
def url_for_override(endpoint, *posargs, _anchor=None, _method=None, _scheme=None, _external=None, self=app, **values):
|
||||
if endpoint == "static":
|
||||
# bandaid for #1
|
||||
if not os.path.exists("/app/static/" + values["filename"]):
|
||||
sys.stderr.write("WARN:: requested {0} from local file, but it doesn't exist in this container. Redirecting to CDN...\n".format(values["filename"]))
|
||||
sys.stderr.flush()
|
||||
if not os.path.exists(path_appdir / "static" / values["filename"]):
|
||||
log.warning("requested {0} from local file, but it doesn't exist in this container. Redirecting to CDN...\n".format(values["filename"]))
|
||||
return "https://cdn.otl-hga.net/seagull/" + values["filename"]
|
||||
|
||||
return orig_url_for(endpoint, *posargs, _anchor=_anchor, _method=_method, _scheme=_scheme, _external=_external, **values)
|
||||
@@ -51,5 +64,5 @@ def render_base_context():
|
||||
base_context_live = True
|
||||
|
||||
@app.route("/core/ping")
|
||||
def aws_healthcheck_ping():
|
||||
def healthcheck_ping():
|
||||
return flask.Response("OK", content_type="text/plain")
|
Reference in New Issue
Block a user