Thanks for all the responses. 
I'll respond to everyone (Omar, Crystal, Stuart, Bodie)
within this message to prevent sending out multiple messages. 

It appears my message was significantly less clear than I thought.
My apologies. 
Let me try again and
then I'll respond directly to messages further down. 

What I'm trying to do is display a python file
that has imbedded HTML within a web browser.
The file is 'hello_world.py' and below are its contents:
  #!/usr/local/bin/python3
  print('Content-type:text/html\n')
  print('<html>')
  print('<body>')
  print('<h1>Hello World</h1>')
  print('</body>')
  print('</html>\n')

Within a browser, I want to be able to access this file
and see 'Hello World' displayed.
Where does this file need to be placed?
What configuration changes need to be made to make this work?

Currently, httpd(8) is running
and I'm able to access HTML files via a web browser.
I've seen mentions online that I needed to run slowcgi(8)
in order to get this to work, so I did 'rcctl enable slowcgi' and
'rcctl start slowcgi'.
Then, I placed 'hello_world.py' in '/var/www/htdocs/test/'
and then added the 'location' configuration to '/etc/httpd.conf'.
Below is the full 'httpd.conf':
  server "test" {
    listen on 10.1.1.1 port 80
    root "/htdocs/test"
    location "*.py" {
      fastcgi
      root "/htdocs/test"
    }
  }

  types {
    include "/usr/share/misc/mime.types"
  }

The reason I was messing with python(1) in chroot
was because that's what I was seeing online.
If that doesn't need to be messed with, great.
However, I don't know what I'd need to do to make this work. 

On Sunday, December 18th, 2022 at 11:18 AM, Omar Polo <o...@omarpolo.com> wrote:

> not exactly, fastcgi is a binary protocol, whereas from what you're
> writing I'm assuming you're trying to run a CGI script written in
> python with slowcgi.
> 
> (this is what I meant with "explain what you're trying to do" as there
> is a big difference between running a python web application and
> running a custom CGI script.)

Sorry. Hopefully what I have at the top of this message
makes it more clear.
I'm guessing the answer is I'm trying to run a python web application,
but honestly, I'm not sure. 
When you say 'custom CGI script', that just confuses me.
I'm assuming that's more backend web development
where data is passed from the server via CGI (slowcgi/fastcgi?)
to python(1).
Whereas python web application
is more of the front end web development
that controls how the page itself looks.
Currently, I'm just trying to load a python file to display content.

> On pypi there is a 'fastcgi' library. 

I'll have to take a look at this.
I didn't think I'd need to install an additional library
if I was just trying to display some HTML content. 

On Sunday, December 18th, 2022 at 11:38 AM, Crystal Kolipe 
<kolip...@exoticsilicon.com> wrote:

> It's probably about one day's work.

What may be one day's worth of work for you may be weeks/months
for me.
I don't forsee this being that easy for me. 

On Sunday, December 18th, 2022 at 1:11 PM, Stuart Henderson 
<stu.li...@spacehopper.org> wrote:

> Surely the goal is to run some particular software and make it available
> via an httpd(8) frontend and not just run python(1) i.e. the Python 
> interpreter?

Actually, I think this is exactly what I'm trying to do right now.
Maybe it's stupid to do this,
but I figured I'd start just with python.
After getting that to work and understanding it, 
then maybe use additional software with python.
See my original message at the top that hopefully better explains
what I'm trying to do. 

>fastcgi
> is more common with other languages but also possible with Python and
> would often be a better fit than trying to run Python directly in a chroot
> via httpd->fastcgi->slowcgi->python(1).

Any guides, resources, or rough instructions on how to do this?

On Sunday, December 18th, 2022 at 3:21 PM, Bodie <bo...@bodie.cz> wrote:

> As was already pointed out by others it may be good to know what
> are you trying to achieve actually aka why you are trying to put
> python in chroot. Especially as you said it works with perl fine
> and that one is in base.

Apologies. Hopefully my message at the top is more clear now.

Reply via email to