Casey Bralla via plug on 6 Feb 2024 07:52:23 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Replacement for Python CGI Module


The python CGI module that I have been using for about 10 years has been deprecated, and I'm struggling to figure out a replacement.  Can somebody give me some insights or point me to a good reference?

I'm using a POST command in an html form in my web page to call a python script that reads the POST data and uses it to execute commands and regenerate a html web page.  I have been loading the python cgi module to read the POST data and take various actions based on that data.

Here's my html code:

<FORM METHOD='Post' ACTION='http://app.mydomain.com/cgi-bin/music.py' >
<INPUT TYPE='Hidden' NAME='CommandLine' VALUE='Prev'>
<INPUT TYPE='SUBMIT' VALUE='Previous Song'>
</FORM>

Here's my html code:

import cgi
FormData    = cgi.FieldStorage()
CommandLine = FormData.getvalue("CommandLine")
if CommandLine == "Prev": pipe = os.popen("/usr/bin/mpc prev")

Since the CGI module is gone, I've got to find another way to get back the functionality.  There is a PIP module called "mycgi", but I haven't been able to get it to work.  (typing in the example code verbatim fails)  The python docs say that the replacement is "multipart", but I'm still trying to digest that.  It seems a LOT more complex than CGI.

Can somebody offer some suggestions for alternatives?  I've heard a little about WSGI, but am confused by what I read, and I don't know enough to be able to ask good questions.

Anyway, hoping somebody can clarify and offer suggested solutions.

TIA!


___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug