python cgi problem with textarea

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adrian Smith

    #1

    python cgi problem with textarea

    This may be more a cgi thing than a Python one, but I'm trying to get
    this page:



    consisting basically of this:

    <FORM ACTION="/cgi-bin/python3.cgi" METHOD="POST">
    <TEXTAREA NAME="essay" COLS=60 ROWS=20 WRAP=HARD></TEXTAREA>
    <P><INPUT TYPE=SUBMIT VALUE="submit" NAME="submitbut ton">
    </FORM>

    ....to print out the contents of the textarea with this cgi script:

    #!/usr/bin/python
    import cgi
    print "Content-type: text/html\n"
    form = cgi.FieldStorag e()
    print form["essay"].value

    ....and I get an internal server error if I have any spaces in the
    textarea, which is really going to limit its usefulness to me. Oddly,
    it seems to work for a friend in the UK who's looked at it, but it
    doesn't work for me here in Japan.

  • placid

    #2
    Re: python cgi problem with textarea

    On Apr 22, 4:08 pm, Adrian Smith <adrian_p_sm... @yahoo.comwrote :
    This may be more a cgi thing than a Python one, but I'm trying to get
    this page:
    >

    >
    consisting basically of this:
    >
    <FORM ACTION="/cgi-bin/python3.cgi" METHOD="POST">
    <TEXTAREA NAME="essay" COLS=60 ROWS=20 WRAP=HARD></TEXTAREA>
    <P><INPUT TYPE=SUBMIT VALUE="submit" NAME="submitbut ton">
    </FORM>
    >
    ...to print out the contents of the textarea with this cgi script:
    >
    #!/usr/bin/python
    import cgi
    print "Content-type: text/html\n"
    form = cgi.FieldStorag e()
    print form["essay"].value
    >
    ...and I get an internal server error if I have any spaces in the
    textarea, which is really going to limit its usefulness to me. Oddly,
    it seems to work for a friend in the UK who's looked at it, but it
    doesn't work for me here in Japan.
    i just tried it and its working. here it is



    maybe the internal server error is because mod_python isn't installed
    assuming your using Apache as your web server

    Cheers


    Comment

    • Jim

      #3
      Re: python cgi problem with textarea

      On Apr 22, 2:08 am, Adrian Smith <adrian_p_sm... @yahoo.comwrote :
      ...and I get an internal server error if I have any spaces in the
      textarea,
      And what error appears in the server error log?

      Comment

      • Adrian Smith

        #4
        Re: python cgi problem with textarea

        On Apr 22, 10:09 pm, placid <Bul...@gmail.c omwrote:
        i just tried it and its working. here it is
        >

        >
        maybe the internal server error is because mod_python isn't installed
        assuming your using Apache as your web server
        Yeah, but it wouldn't work *at all* in that case, would it? ATM it
        seems to work as long as the textarea input has no spaces.

        Comment

        • Adrian Smith

          #5
          Re: python cgi problem with textarea

          On Apr 22, 11:40 pm, Jim <jim.heffe...@g mail.comwrote:
          On Apr 22, 2:08 am, Adrian Smith <adrian_p_sm... @yahoo.comwrote :...and I
          get an internal server error if I have any spaces in the textarea,
          >
          And what error appears in the server error log?
          I've just asked my web provider why I don't appear to have a server
          error log, as a matter of fact - I'll post it if and when they reply.

          Comment

          • Graham Dumpleton

            #6
            Re: python cgi problem with textarea

            On Apr 22, 11:09 pm, placid <Bul...@gmail.c omwrote:
            On Apr 22, 4:08 pm, Adrian Smith <adrian_p_sm... @yahoo.comwrote :
            >
            >
            >
            This may be more a cgi thing than a Python one, but I'm trying to get
            this page:
            >>
            consisting basically of this:
            >
            <FORM ACTION="/cgi-bin/python3.cgi" METHOD="POST">
            <TEXTAREA NAME="essay" COLS=60 ROWS=20 WRAP=HARD></TEXTAREA>
            <P><INPUT TYPE=SUBMIT VALUE="submit" NAME="submitbut ton">
            </FORM>
            >
            ...to print out the contents of the textarea with this cgi script:
            >
            #!/usr/bin/python
            import cgi
            print "Content-type: text/html\n"
            form = cgi.FieldStorag e()
            print form["essay"].value
            >
            ...and I get an internal server error if I have any spaces in the
            textarea, which is really going to limit its usefulness to me. Oddly,
            it seems to work for a friend in the UK who's looked at it, but it
            doesn't work for me here in Japan.
            >
            i just tried it and its working. here it is
            >

            >
            maybe the internal server error is because mod_python isn't installed
            assuming your using Apache as your web server
            You do not need mod_python installed to be able to run CGI scripts,
            thus has nothing to do with mod_python.

            Graham

            Comment

            • placid

              #7
              Re: python cgi problem with textarea

              On Apr 23, 1:01 am, Adrian Smith <adrian_p_sm... @yahoo.comwrote :
              On Apr 22, 10:09 pm, placid <Bul...@gmail.c omwrote:
              >
              i just tried it and its working. here it is
              >>
              maybe the internal server error is because mod_python isn't installed
              assuming your using Apache as your web server
              >
              Yeah, but it wouldn't work *at all* in that case, would it? ATM it
              seems to work as long as the textarea input has no spaces.
              it doest work because the "space" character isnt interpreted
              correctly, you need
              to change the space characters too &nbsp;

              Cheers


              Comment

              • Peter Otten

                #8
                Re: python cgi problem with textarea

                Adrian Smith wrote:
                ...and I get an internal server error if I have any spaces in the
                textarea, which is really going to limit its usefulness to me. Oddly,
                While debugging you should put
                #!/usr/bin/python
                import cgitb
                cgitb.enable()
                import cgi
                print "Content-type: text/html\n"
                form = cgi.FieldStorag e()
                print form["essay"].value
                at the beginning of your cgi -- just in case the error is in the python
                script.

                Peter

                Comment

                • Tim Roberts

                  #9
                  Re: python cgi problem with textarea

                  placid <Bulkan@gmail.c omwrote:
                  >On Apr 23, 1:01 am, Adrian Smith <adrian_p_sm... @yahoo.comwrote :
                  >On Apr 22, 10:09 pm, placid <Bul...@gmail.c omwrote:
                  >>
                  i just tried it and its working. here it is
                  >>>>
                  maybe the internal server error is because mod_python isn't installed
                  assuming your using Apache as your web server
                  >>
                  >Yeah, but it wouldn't work *at all* in that case, would it? ATM it
                  >seems to work as long as the textarea input has no spaces.
                  >
                  >it doest work because the "space" character isnt interpreted
                  >correctly, you need to change the space characters too &nbsp;
                  What??? Did you even read the problem description?
                  --
                  Tim Roberts, timr@probo.com
                  Providenza & Boekelheide, Inc.

                  Comment

                  • placid

                    #10
                    Re: python cgi problem with textarea

                    On Apr 24, 4:52 pm, Tim Roberts <t...@probo.com wrote:
                    placid <Bul...@gmail.c omwrote:
                    On Apr 23, 1:01 am, Adrian Smith <adrian_p_sm... @yahoo.comwrote :
                    On Apr 22, 10:09 pm, placid <Bul...@gmail.c omwrote:
                    >
                    i just tried it and its working. here it is
                    >>
                    maybe the internal server error is because mod_python isn't installed
                    assuming your using Apache as your web server
                    >
                    Yeah, but it wouldn't work *at all* in that case, would it? ATM it
                    seems to work as long as the textarea input has no spaces.
                    >
                    it doest work because the "space" character isnt interpreted
                    correctly, you need to change the space characters too &nbsp;
                    >
                    What??? Did you even read the problem description?
                    oops...i did read the problem description, but i when i tried the code
                    it worked for me and when i put spaces into the TextArea it wasn't
                    reflected correctly back. So i thought this was the problem.

                    Adrian, can you still try replacing spaces with &nbsp; via the
                    following;

                    #!/usr/bin/python
                    import cgi
                    import urllib
                    import cgitb
                    cgitb.enable()
                    print "Content-type: text/html\n"
                    form = cgi.FieldStorag e()
                    #print urllib.quote_pl us(form["essay"].value)

                    for char in form["essay"].value:
                    if char == ' ':
                    print "&nbsp;"
                    else:
                    print char


                    Cheers

                    Comment

                    • Adrian Smith

                      #11
                      Re: python cgi problem with textarea

                      On Apr 24, 8:00 pm, placid <Bul...@gmail.c omwrote:
                      oops...i did read the problem description, but i when i tried the code
                      it worked for me and when i put spaces into the TextArea it wasn't
                      reflected correctly back. So i thought this was the problem.
                      >
                      Adrian, can you still try replacing spaces with &nbsp; via the
                      following;
                      >
                      #!/usr/bin/python
                      import cgi
                      import urllib
                      import cgitb
                      cgitb.enable()
                      print "Content-type: text/html\n"
                      form = cgi.FieldStorag e()
                      #print urllib.quote_pl us(form["essay"].value)
                      >
                      for char in form["essay"].value:
                      if char == ' ':
                      print "&nbsp;"
                      else:
                      print char
                      >
                      Cheers
                      I'll try it...but I think it may be a problem on the server end. It's
                      not showing up in the server logs, either.

                      Comment

                      Working...