2017-07-31 22:37 GMT+02:00 Christopher McGrath <mcgrath...@hotmail.com>:
> Someone told me the problem is within the second line of the code. > > > print ("Content-type: text/html") > print (" ") > print ("<html><head>") > print ("") > print ("</head><body>") > print ("Hello Python.") > print ("</body></html>") > > > There should be no space. I copied and pasted that code from somewhere and > somehow that space has some hidden char that python didn't like... > > > The one "who" does not like that space is not the Python, but the CGI standard. https://en.wikipedia.org/wiki/Common_Gateway_Interface citation: print "Content-type: text/plain\n\n"; end citation there is blank line after content-type. But when you use a framework, you do not have to care with cgi ;-) BR George > > *Christopher McGrath* > > > > *www.aawisdom.com <http://www.aawisdom.com> (716) 240-7786* > > > > ------------------------------ > *From:* georgefisch...@gmail.com <georgefisch...@gmail.com> on behalf of > George Fischhof <geo...@fischhof.hu> > *Sent:* Monday, July 31, 2017 8:34 PM > *To:* Christopher McGrath > *Cc:* tutor@python.org > *Subject:* Re: [Tutor] Python isn't working with Apache (Windows) > > > > 2017-07-31 7:31 GMT+02:00 Christopher McGrath <mcgrath...@hotmail.com>: > >> I am trying to run a simple python web script in a browser with apache. I >> have apache installed and running perfectly. I installed Ruby and Perl >> using instructions from here and worked perfect. >> http://editrocket.com/articles/python_apache_windows.html >> >> I did have to change my “shebang lines” for PERL and RUBY like these: >> #!Q:\LifeForce\perl\perl\bin\perl.exe >> #!Q:\LifeForce\Ruby24-x64\bin\ruby.exe >> As you can see, I didn’t install them on C: drive. They worked. >> >> I had Python 3.6 installed before and tried to test with these >> #!Q:\LifeForce\Python36-32\Scripts\pip3.exe >> #!Q:\LifeForce\Python36-32\Scripts\pip.exe >> #!Q:\LifeForce\Python36-32\Scripts\pip2.6.exe >> All the pip files in the Script directory. >> I also tried with #!Q:\LifeForce\Python36-32\python.exe. This one works >> worked from Window Command, but didn’t work from web browser like PERL and >> RUBY. >> I tried downgrading to Python 2.7 and installed directly at C: drive and >> tested with >> #!C:\Python27\python.exe >> #!C:\Python27\Scripts\pip2.7.exe >> #!C:\Python27\Scripts\pip2.exe >> #!C:\Python27\Scripts\pip.exe >> Nothing worked. I don’t have any idea anymore. Please help! >> This is the simple code: >> print ("Content-type: text/html") >> print (" ") >> print ("<html><head>") >> print ("") >> print ("</head><body>") >> print ("Hello Python.") >> print ("</body></html>") >> >> I am trying to run directly from Apache htdoc dir. Not from cgi dir. I >> think something is wrong with the shebang line. >> This is the error output in the web browser: >> Internal Server Error >> The server encountered an internal error or misconfiguration and was >> unable to complete your request. >> Please contact the server administrator at postmaster@localhost to >> inform them of the time this error occurred, and the actions you performed >> just before this error. >> More information about this error may be available in the server error >> log. >> Additionally, a 500 Internal Server Error error was encountered while >> trying to use an ErrorDocument to handle the request. >> This is what is shown in Apache’s error log: >> [Mon Jul 31 01:06:54.266478 2017] [cgi:error] [pid 5156:tid 1688] [client >> 98.5.128.152:51723] malformed header from script 'test.py': Bad header: >> [Mon Jul 31 01:06:54.270479 2017] [authz_core:error] [pid 5156:tid 1688] >> [client 98.5.128.152:51723] AH01630: client denied by server >> configuration: C:/Apache24 >> >> >> >> >> >> Christopher McGrath >> >> [http://aawisdom.com/Top_of_main_files/BizCard-Front-hotmailSignature.jpg >> ] >> [http://aawisdom.com/Top_of_main_files/image001.gif] >> www.aawisdom.com<http://www.aawisdom.com> (716) 240-7786 >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor >> > > > Hi Christopher, > > unfortunately I do not know much about your problem but I think it can be > useful to read about WSGI and WSGI web services, servers: > > https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface > > https://www.python.org/dev/peps/pep-0333/ > > https://wiki.python.org/moin/WebFrameworks > > https://www.fullstackpython.com/wsgi-servers.html > > > According to these articles I chose Flask for application server (it has a > built-in development webserver as well) and Waitress for webserver. > Maybe you can give them a try ;-) > > BR > George > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor