python - Blank page when trying to set up Apache and Django together -
i'm trying set python , django work apache.
the django project gave me nothing blank page, i've tried sample i've found in many places:
def application(environ, start_response): status = '200 ok' output = 'this website!' response_headers = [('content-type', 'text/plain'), ('content-length', str(len(output)))] start_response(status, response_headers) return [output]
i've added following lines @ beginning of app.py file:
#!c:/program files/python34/python.exe print('content-type: text/html') print('\n\n')
i still blank page.
if add following code:
def testfunction(text): print(text) testfunction('this works')
i appropriate output ('this works') guess python script is running. how callable application(environ, start_response) called ?
i'm new python/django , new apache may missing trivial, here's i've tried:
- looking apache log files, there's nothing in error.log (even though i've set loglevel 'info')
- making sure no other modules interfere (no mod_php or mod_python loaded)
- adding wsgiapplicationgroup %{global}
- not using virtualhost or virtualenv keep simple
- checking permissions on files , folders (all have read & execute checked)
here section of apache config file:
wsgiscriptalias /wsgi "c:/pythonworkspace/app.py" <directory "c:/pythonworkspace"> options execcgi addhandler cgi-script .cgi .py require granted </directory>
config is: windows server 2008 / apache 2.4 w mod_wsgi / python 3.4 / django 1.6.5
thanks in advance pointers !
this code used cgi
print('content-type: text/html') print('\n\n') print('this website!')
this code used wsgi
def application(environ, start_response): status = '200 ok' output = 'this website!' response_headers = [('content-type', 'text/plain'), ('content-length', str(len(output)))] start_response(status, response_headers) return [output]
apache configured use cgi
.py
files
addhandler cgi-script .cgi .py
to use wsgi
need
addhandler cgi-script .cgi # removed .py addhandler wsgi-script .py
Comments
Post a Comment