base game code; there's no game here (yet)
This commit is contained in:
22
app/index.wsgi
Normal file
22
app/index.wsgi
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import gevent.monkey
|
||||
gevent.monkey.patch_all()
|
||||
|
||||
import logging
|
||||
|
||||
import flask
|
||||
from gevent.pywsgi import WSGIServer
|
||||
|
||||
from pylocal import core
|
||||
|
||||
@core.app.route("/")
|
||||
def index():
|
||||
if not core.base_context_live:
|
||||
core.render_base_context()
|
||||
return flask.render_template("main_page.j2", **core.base_context)
|
||||
|
||||
if __name__ == "__main__":
|
||||
#core.app.run("0.0.0.0", 1337)
|
||||
http_server = WSGIServer(('', 80), core.app, log=logging.getLogger(name="gevent"))
|
||||
http_server.serve_forever()
|
29
app/pylocal/core.py
Normal file
29
app/pylocal/core.py
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
import flask
|
||||
|
||||
app = flask.Flask("seagull-game", root_path="/app")
|
||||
|
||||
base_context = {}
|
||||
base_context_live = False
|
||||
|
||||
def render_base_context():
|
||||
global base_context
|
||||
global base_context_live
|
||||
|
||||
print(flask.request.host)
|
||||
|
||||
domain_components = flask.request.host.split(".")
|
||||
base_domain = ".".join(domain_components[-2:])
|
||||
|
||||
# all this wind up for...
|
||||
if base_domain == "otl-hga.net": # production, use assets from S3
|
||||
base_context["styles"] = ["https://cdn.otl-hga.net/seagull/css/seagull.css"]
|
||||
base_context["scripts"] = ["https://cdn.otl-hga.net/seagull/js/seagull.js"]
|
||||
base_context["seagull_pic"] = "https://cdn.otl-hga.net/seagull/image/seagull.jpg"
|
||||
else: # dev, serve files from here
|
||||
base_context["styles"] = [flask.url_for("static", filename="css/seagull.css")]
|
||||
base_context["scripts"] = [flask.url_for("static", filename="js/seagull.js")]
|
||||
base_context["seagull_pic"] = flask.url_for("static", filename="image/seagull.jpg")
|
||||
|
||||
base_context_live = True
|
2
app/requirements.txt
Normal file
2
app/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Flask==2.2.2
|
||||
gevent==22.10.2
|
39
app/templates/main_page.j2
Normal file
39
app/templates/main_page.j2
Normal file
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Seagull Game</title>
|
||||
{%- for style in styles -%}
|
||||
<link rel="stylesheet" href="{{ style }}">
|
||||
{%- endfor -%}
|
||||
{%- for script in scripts -%}
|
||||
<script src="{{ script }}"></script>
|
||||
{%- endfor -%}
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<h1>This doesn't work without JavaScript.</h1><br />
|
||||
<h2>You're probably using a browser extension or privacy tool that disables it.</h2>
|
||||
</noscript>
|
||||
<div id="root">
|
||||
|
||||
<div id="main-sidebar">
|
||||
<div id="side-seagull-image"> <img width="256" src={{ seagull_pic }}> </div>
|
||||
<div id="side-seagull-name"><span id="lbl-seagull-name">Nameless</span> <a href="javascript:change_seagull_name()">✏️</a></div>
|
||||
<div id="side-seagull-name-editor"><input type="text" id="edt-seagull-name"> <a href="javascript:confirm_seagull_name()">✅</a><a href="javascript:cancel_seagull_name()">❌</a></div>
|
||||
<div id="side-seagull-stats">
|
||||
<p id="side-seagull-lvl">Lv 1 LoadError</p>
|
||||
<p id="side-seagull-misc">
|
||||
Colony: 1337<br />
|
||||
Shinies: 420<br />
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content">
|
||||
<div id="main-day-stats">It has been <span id="main-day-counter">a cosmically unknowable number of</span> days.</div>
|
||||
<div id="main-log"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user