AttributeError: partially initialized module 'cgi' has no attribute 'FieldStorage' (most likely due

Discussion in 'Python' started by Rasu, May 17, 2020.

  1. Rasu

    Rasu

    Joined:
    May 17, 2020
    Messages:
    1
    Likes Received:
    0
    Code (Python):
    import cgi
    import cgitb
    import time
    cgitb.enable()
    now = time.strftime("%A %d %B %Y")
    form = cgi.FieldStorage()
    name = form.getvalue('name', 'new user')
    def print_content():
        print("Content-type: text/html")
        print()
    def print_header():
        print("""<html>
         <head>
         <title>Simple CGI form</title>
         </head>
         <body>"""
    )
    def print_form():
         print("""
         <form action='form.cgi'>
         Enter your name: <input type='text' name='name' />
         <input type='submit' />
         </form>
         """
    )
    def print_footer():
        print("</body></html>")
    print_content()
    print_header()
    print("""<h1>It's {0!s}!</h1>
    <p>Hello {1!s}, your server is correctly set up to run Python programs.</p>"""
    .format(now,
    name))
    print_form()
    print_footer()
     
    Last edited by a moderator: May 18, 2020
    Rasu, May 17, 2020
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.