From e5ce7f64268e3e3c37fbe3a4a08c2115698143c8 Mon Sep 17 00:00:00 2001 From: LockeShor <75901583+LockeShor@users.noreply.github.com> Date: Sat, 19 Sep 2026 20:41:42 -0400 Subject: [PATCH] add main page and multiple stories --- README.md | 11 +++++++++-- main.html | 11 +++++++++++ server.py | 20 ++++++++++++-------- story copy.json => stories/test.json | 0 story.json => stories/water-willow.json | 0 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 main.html rename story copy.json => stories/test.json (100%) rename story.json => stories/water-willow.json (100%) diff --git a/README.md b/README.md index 8397656..1c2bb00 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,11 @@ # cyoa-discord -[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 \ No newline at end of file +[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 + +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 diff --git a/main.html b/main.html new file mode 100644 index 0000000..afdd466 --- /dev/null +++ b/main.html @@ -0,0 +1,11 @@ + + + + + + Test + + +test + + \ No newline at end of file diff --git a/server.py b/server.py index 4d2fc3a..82d32bf 100644 --- a/server.py +++ b/server.py @@ -5,17 +5,21 @@ app = Flask(__name__) @app.route("/") -def game(): +def mainPage(): + return open("main.html").read() + +@app.route("/") +def game(path): + if "Discord" not in str(request.user_agent): + return mainPage() gamecode = request.args.get('code')[:-1] - - #return open("page copy.html", "r").read() - #print(buildHTML(gamecode)) - - return buildHTML(gamecode) + gameName = request.path[1:] + print(gameName) + return buildHTML(gamecode,gameName) -def buildHTML(gamecode): - with open("story.json", "r") as f: +def buildHTML(gamecode, gameName): + with open("stories/" + gameName.replace(".", "") + ".json", "r") as f: print("\n\n") story = json.loads(f.read()) nodeName = "start" diff --git a/story copy.json b/stories/test.json similarity index 100% rename from story copy.json rename to stories/test.json diff --git a/story.json b/stories/water-willow.json similarity index 100% rename from story.json rename to stories/water-willow.json