------- Original Message -------
On Tuesday, December 20th, 2022 at 6:44 PM, Crystal Kolipe 
<kolip...@exoticsilicon.com> wrote:

If you don't mind, I'd like to respond to some of this later.
I think I better understand some of my confusions,
but I'm not fully there yet.

Currently, I've had no issues displaying content.
I can display HTML from within a python file
and run python code to alter what's displayed in HTML.
All good stuff.

However, the 'cgi' module is giving me trouble that I can't resolve.
It simply won't import without errors.

Why am I trying to import the 'cgi' module?
What I want to do is pass data.
For instance, here's 'test.py':
  #!/usr/local/bin/python3
  
  print ('''
    <form action="#" method="post">
      <label for="name">Name</label>
      <input type="text" name="name" id="name" required>
      <button type="submit">Submit</button>
    </form>
  ''')

  print(f"Your name is 'name_goes_here'")

The above is just a simple example that has one input field ('name').
In order to grab the 'name' inputted by the user,
I need to use the 'cgi' module.
The python code above doesn't contain anything
for the 'cgi' module as I can't import it.
I just thought showing an example might avoid any confusion.

As for what's the problem with the 'cgi' module,
below is a test file called 'cgi-test.py':
  #!/usr/local/bin/python3

  import cgi

When I run 'chroot /var/www htdocs/test/cgi-test.py',
I get the below:

    File "/usr/local/lib/python3.9/email/header.py", line 14,
         in <module>
      import binascii
  ImportError: Cannot load specified object

I know, chroot is bad bad.
I think once I can resolve this,
I'll go back through your responses
and attempt to move away from chroot and start using fastcgi.

I tried to troubleshoot the above error,
but I haven't gotten anywhere.
My first thought was where is this module located,
so I ran 'python3' to run the Python Interpreter
and entered the below:
  >>> import binascii
  >>> binascii.__file__
  '/usr/local/lib/python3.9/lib-dynload/binascii.cpython-39.so'

So that's the location of the module.
It is located in the same path within '/var/www/'
and it also has the correct permissions,
but unsure what's the problem with importing it.

Reply via email to