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.
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.
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.
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.