News for hackers. Stuff that matters.
Re:Python finally offloads some batteries by throwaway81523 on Friday March 18, 2022 @12:28AM (#30718748)
This is stupid. I use cgi all the time. My cheap Hetzner single core vps can fork a Linux process 10k times a second, so I don't want to hear about forking being too slow until Django can serve pages that fast.

Cgi is still the simplest way to get a basic web script running, without worrying about lingering state between page hits, etc. Doesn't Linus always shut down such discussions regarding the Linux kernel with "we don't break userspace"? Python should learn something from that.

Re:Python finally offloads some batteries by postpawl on Friday March 18, 2022 @01:07AM (#30718918)
Interesting, I’ve never seen the cgi module used before. It’s good to know it exists.

Here’s an example for those interested: https://dzone.com/articles/python-simple-http-server-with-cg...

Re:Python finally offloads some batteries by throwaway81523 on Friday March 18, 2022 @11:10AM (#30723291)
Yep, if you want to throw a ghetto GUI onto your python script, easiest way is to run CGIHTTPServer (now renamed in py3), write some 1990's style basic HTML, and point a browser at it. Use for customer facing sites? No. But for your internal status checking script or personal photo tagger, it's low fuss, low dependencies, and completely practical.
Re:Python finally offloads some batteries by sciurus on Friday March 18, 2022 @03:50PM (#30726685)
It's not forking the process that's a concern, it's what happens next. How slow is Django to start up? Do you want to pay that penalty for every request?
Re:Python finally offloads some batteries by throwaway81523 on Saturday March 19, 2022 @02:01AM (#30731523)
Django as a cgi does sound painful, but that's because it's huge. Most cgi scripts I've written are quite simple. And they rarely have to serve 100s of requests per second. And of course it's possible to optimize the startup time, e.g. by dumping an already-initialized version of the script (even django). Emacs has done that forever. It wouldn't surprise me if there is some way to do it in Python.

I remember reading somewhere that amazon.com was originally implemented as CGI's written in C. And, Perl cgi scripts served the whole web for many years, on servers much slower than what we have now.