On 8/31/24 8:32 AM, Sadeep Madurange wrote:
> Hello,
>
> I have a python script (flask.py) with the following content on an
> OpenBSD 7.5 server:
>
> #! /usr/local/bin/python3
> print("hello, world!")
. . .
> Then I added the following config to /etc/httpd.conf:
>
> server "localhost" {
> listen on * port 8080
> location "/*" {
> fastcgi { param SCRIPT_FILENAME "/cgi-bin/flask.py" }
> }
> }
>
> restarted httpd, and executed the following curl request:
>
> $ curl http://localhost:8080/
>
> However, I keep getting 500 internal server error. Not sure what I'm
> doing wrong, so any help is much appreciated.
First, it looks like your script is written with the expectation of
behaving like a CGI script: a process spawned by the web server and
configured so that stdout of the script is the body of the HTTP
response. That's not how FastCGI works.
Since your httpd.conf doesn't specify a socket, httpd(8) is looking for
a Unix domain socket at /var/www/run/slowcgi.sock, created and managed
by an external program (like your Python script) to speak FastCGI over.
You probably want/need an existing Python3 FastCGI server to handle
those details; I'm not a big Python developer but it seems like flup-py3
is what you want for that.
That might be enough to get you started, or point you in the right
direction.
Matthew
No comments:
Post a Comment