Reputation: 7845
Here's my sample app:
def application(environ, start_response):
status = '200 OK'
output = b"""
<html>
<head>
</head>
<body>
<h1>It works!</h1>
</body>
</html>
"""
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
When I run it, I get:
As you can see, the html is completely ignored and treated as pure text. I'm a complete beginner with mod_wsgi, so...
How can I deal with requests and responses natively? I'm using this word because when I google "wsgi response object", I get Werkzeug and WebOb for example, or random Django-related stuff. I want pure python / native material. So,
Ho do I send an HTML response with mod_wsgi?
Upvotes: 0
Views: 788
Reputation: 599450
This has nothing to do with mod_wsgi.
For some reason you've explicitly set the content type header to be "text/plain", so the browser will interpret it as, well, text. Don't do that: it should be "text/html".
Note, you really shouldn't reject the frameworks. Writing applications in pure wsgi is possible, but unnecessarily complex; a framework simply abstracts away that complexity.
Upvotes: 2