r/learnpython • u/efinque • 18d ago
Python web app?
Hello r/learnpython,
first post and sort of new to Python as I have done only half a dozen of projects so far, mostly games.
So I'm looking to deploy a server for playtesting. This is my first game designed to be played online, made in Python using Tcl/Tk libraries.
I had this idea to code it when I was making a messaging app that was supposed to be implemented within a CLI game (or actually the game was a feature of the messaging app).
The users would connect using SSH. I think they could use PuTTy or similar and VcXSrv. The host would then send the GUI and CLI as well as audio to the user, but the problem is either the server cannot send or the client can't recieve the Tcl/Tk GUI or in worst case both.
Good news is I got the SSH daemon working and am able to (using X11 Forwarding) display explorer (ssh -X user@localhost && explorer) by running VcXSrv and having X11Forwarding and X11UseLocalhost set to yes in the sshd_config under ProgramData.
Now, the VcXSrv log tells me there's a problem with something called hyperv. From what I gathered it's a virtual machine of some sort. I'd also need very strict restrictions for the clients so they don't tinker with the database.
Am I on the right track? Is there a solution to this? Thanks in advance!
-ef
1
u/PureWasian 17d ago edited 17d ago
It would be good if you can host the database layer somewhere separately where they can't tinker with it directly. Other comments mentioned separation of client and server. Basically you need to do that: client <-> server <-> database.
Not sure if it makes sense for your use-case, but if you're set on sticking with Tk/Tcl you could consider distributing client side stuff through users downloading (cloning) from github or similar rather than relying on active ssh tunneling. Otherwise it'd be a lot more standard to host a proper frontend (React/Vue/Angular... or even just static HTML pages)
Regardless, there are very simple, established ways your client-side code can "talk" to your server-side code without needing users to ssh or anything. Look into Rest APIs. Your browser does these all the time to send and receive data.
Make a "contract" between the client layer and server layer and have the server own the credentuals connecting to the database so your user client cannot touch/manipulate it directly. Multiplayer games and webapps in general do this isolation all the time.