So, are stupid #Python CGI scripts now #Deprecated? I can't seem to find a #CGI replacement. Or is CGI just deprecated?

@doctorwhom

For Python web apps, ASGI is generally used. It's got a lot of similarities to CGI, and many improvements.

If you just want to run a simple script, you can write your script to use the ASGI interface directly, and just run it under a server like gunicorn/uvicorn, or an ASGI module for Apache or whatever other webserver you like.

If you want to do something fancier, there are several good frameworks for #ASGI use.

@cazabon

While I didn't know about ASGI before today, it looks nice, might bring it up at work. But I really just want to do is parse a QUERY_STRING, look for a few files & "<img" display them.

Stupid home projects are getting harder.

@doctorwhom

What you're looking for, probably, is Flask and the underlying libraries it uses. It's a web "microframework". You can write a script to do what you describe with a bare minimum of code and pain.

You can implement a surprising amount of functionality in a screenful of code with Flask.

@doctorwhom

Oh, and if ASGI is overkill for your application - don't need high-performance async stuff - WSGI, which it is based on, is even easier to write scripts for.

#WSGI #ASGI

@doctorwhom looks like it's just the CGI module which is deprecated: https://discuss.python.org/t/alternative-function-for-deprecated-cgi/21960
Alternative function for deprecated cgi

To my surprise, I received the following warning in my Apach system: DeprecationWarning: ‘cgi’ is deprecated and slated for removal in Python 3.13. I need the function cgi.FieldStorage() for extracting parameters from each Internet request from my web system such as ‘?aaa=111&bbbb=222&ccc=333’. What is the best alternative function for cgi?

Discussions on Python.org

@kevin

The CGI module has issues, it's allowed to go away. But there should still be a stupid CGI module. For simple scripts. Parse the input, run code for the output, provide a http header for the output. I'm already jumping through SELinux hoop to get that to work. Just the CGI interface, no extra apache modules.

Or is there an option & I'm missing it?

I don't want to create, even an sqlite, database for everything.

@doctorwhom this isn't my specialty and I'm not involved in any of the CGI module deprecation discussions, but I believe CGI itself should still work for Apache. The usual alternative is a micro-framework like Flask or Bottle or to make use of the `http.server` module to handle the requests.