add main page and multiple stories

This commit is contained in:
LockeShor
2026-09-19 20:41:42 -04:00
parent 5ffdc0bbb2
commit e5ce7f6426
5 changed files with 32 additions and 10 deletions
+9 -2
View File
@@ -1,4 +1,11 @@
# cyoa-discord # cyoa-discord
[NO AI USAGE] [NO AI USAGE]
Simple choose your own adventure story hosted over Discord's new link embed V2 system, controlled with sed commands to edit your message's query value Simple choose your own adventure story hosted over Discord's new link embed V2 system, controlled with sed commands to edit your message's query value
it's cache friendly as well, since the same code will always have the same result
stories are easy to store as json files
and you can switch between stories through pathing
main page also displays how to play the game (WIP)
this is just a fun little test I wanted to try with discords new scraper embed system they announced
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
</head>
<body>
test
</body>
</html>
+12 -8
View File
@@ -5,17 +5,21 @@ app = Flask(__name__)
@app.route("/") @app.route("/")
def game(): def mainPage():
return open("main.html").read()
@app.route("/<path:path>")
def game(path):
if "Discord" not in str(request.user_agent):
return mainPage()
gamecode = request.args.get('code')[:-1] gamecode = request.args.get('code')[:-1]
gameName = request.path[1:]
#return open("page copy.html", "r").read() print(gameName)
#print(buildHTML(gamecode)) return buildHTML(gamecode,gameName)
return buildHTML(gamecode)
def buildHTML(gamecode): def buildHTML(gamecode, gameName):
with open("story.json", "r") as f: with open("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"