dockerize (did it myself this time!) and rearrange directories
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
|||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
VOLUME [ "/app/assets" ]
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV FLASK_APP=server.py
|
||||||
|
ENV FLASK_RUN_HOST=0.0.0.0
|
||||||
|
ENV FLASK_RUN_PORT=1387
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
COPY server.py .
|
||||||
|
|
||||||
|
EXPOSE 1387/tcp
|
||||||
|
|
||||||
|
CMD ["flask", "run", "--debug"]
|
||||||
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
@@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "1387:1387"
|
||||||
|
volumes:
|
||||||
|
- ./assets:/app/assets:ro
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<html><head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
||||||
<title>Choose Your Own Adventure</title>
|
|
||||||
<meta name="Generator" content="Cocoa HTML Writer">
|
|
||||||
<meta name="CocoaVersion" content="2685.7">
|
|
||||||
<style type="text/css">
|
|
||||||
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
|
|
||||||
</style>
|
|
||||||
<script id="discord:component-embed" type="application/json">
|
|
||||||
{
|
|
||||||
"component": {
|
|
||||||
"type": 17,
|
|
||||||
"accent_color": {{Color}},
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"type": 10,
|
|
||||||
"content": "{{CurrText}}\n{{Choices}}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<meta property="og:type" content="website">
|
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
|
||||||
<meta name="theme-color" content="#5865f2">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p class="p1">test</p>
|
|
||||||
|
|
||||||
|
|
||||||
</body></html>
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
flask
|
||||||
@@ -6,7 +6,7 @@ app = Flask(__name__)
|
|||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def mainPage():
|
def mainPage():
|
||||||
return open("main.html").read()
|
return open("assets/main.html").read()
|
||||||
|
|
||||||
@app.route("/<path:path>")
|
@app.route("/<path:path>")
|
||||||
def game(path):
|
def game(path):
|
||||||
@@ -14,15 +14,15 @@ def game(path):
|
|||||||
return mainPage()
|
return mainPage()
|
||||||
gameName = request.path.split("/")[1]
|
gameName = request.path.split("/")[1]
|
||||||
if gameName == "img":
|
if gameName == "img":
|
||||||
print("returning image", "images/" + request.path.split("/")[-1].replace(".", "")[:-3] + ".png")
|
print("returning image", "assets/images/" + request.path.split("/")[-1].replace(".", "")[:-3] + ".png")
|
||||||
return send_file("images/" + request.path.split("/")[-1].replace(".", "")[:-3] + ".png", mimetype="image/png")
|
return send_file("assets/images/" + request.path.split("/")[-1].replace(".", "")[:-3] + ".png", mimetype="image/png")
|
||||||
gamecode = request.args.get('code')[:-1]
|
gamecode = request.args.get('code')[:-1]
|
||||||
print(gameName)
|
print(gameName)
|
||||||
return buildHTML(gamecode,gameName)
|
return buildHTML(gamecode,gameName)
|
||||||
|
|
||||||
|
|
||||||
def buildHTML(gamecode, gameName):
|
def buildHTML(gamecode, gameName):
|
||||||
with open("stories/" + gameName.replace(".", "") + ".json", "r") as f:
|
with open("assets/stories/" + gameName.replace(".", "") + ".json", "r") as f:
|
||||||
print("\n\n")
|
print("\n\n")
|
||||||
story = json.loads(f.read())
|
story = json.loads(f.read())
|
||||||
nodeName = "start"
|
nodeName = "start"
|
||||||
@@ -42,7 +42,7 @@ def buildHTML(gamecode, gameName):
|
|||||||
color = story["SPECIAL-color"] if "SPECIAL-color" in story.keys() else "0"
|
color = story["SPECIAL-color"] if "SPECIAL-color" in story.keys() else "0"
|
||||||
print(str(request.user_agent) + "\n",currText,choices,color)
|
print(str(request.user_agent) + "\n",currText,choices,color)
|
||||||
|
|
||||||
with open('page.html', "r") as page:
|
with open('assets/page.html', "r") as page:
|
||||||
page = page.read()
|
page = page.read()
|
||||||
page = page.replace("{{CurrText}}", currText.replace('"', '\\"'))
|
page = page.replace("{{CurrText}}", currText.replace('"', '\\"'))
|
||||||
page = page.replace("{{Choices}}", choices)
|
page = page.replace("{{Choices}}", choices)
|
||||||
|
|||||||
Reference in New Issue
Block a user