💾 Archived View for yretek.com › en › myfirstcgi.gmi captured on 2022-01-08 at 14:22:33. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
Dear unknown person, let me show you my first gopher cgi script that could potentially do something useful:
#!/usr/bin/env python3 import os print("1bala\t/cgi-bin/?bala\tyretek.com\t70") print("1rala\t/cgi-bin/?rla\tyretek.com\t70") if(os.environ['QUERY_STRING']=="bala"): print(f"Thats a bala") else: print("nada") print(os.environ['QUERY_STRING'])
OK, so this is as basic as it gets. Line 3 and 4 print gopher links. As gopher require tabs to separate fields for their url/link format protocol, I'm using escaped tab characters to make them visible. Note that with python editors a tab key press can be transformed into spaces, so it's also a benifit to be able to see those tabs, just for the peace of mind.
Anyway, as the script is actually called gophermap (the equivalent to index.html in html), I only need to add the query string to the selector.
Then I can get the QUERY STRING though os.environ, and that's just a string I can use to record the player action and the game state.
This could follow some easy to extract pattern such as, I don't know
?action-9A8456-12
where
That query string could also be used for a player to "save" the game. Just add it to the url to "load".
So that's that, for now, FWIW
Oh, and also, if you are boldly trying out this mess yourself. The script, at least on gophernicus server, must be placed on a folder called /cgi-bin/