Skip to content Skip to sidebar Skip to footer

Blank Page When Trying To Set Up Apache And Django Together

I'm trying to set up Python and Django to work together with Apache. The Django project gave me nothing but a blank page, so I've tried a sample I've found in many places: def appl

Solution 1:

This code is used by CGI

print('Content-Type: text/html')
print('\n\n')

print('This is my Website!')

This is code is used by WSGI

def application(environ, start_response):

    status = '200 OK'output = 'This is my Website!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

Apache is configured to use CGI for .py files

AddHandler cgi-script .cgi .py    

To use WSGI you need

AddHandler cgi-script .cgi # removed .py
AddHandler wsgi-script .py 

Post a Comment for "Blank Page When Trying To Set Up Apache And Django Together"