Revision abe2d7e5
Added by David Sorber about 13 years ago
| 525.743/code/web/app.wsgi | ||
|---|---|---|
|
|
||
|
# Generate the stream and then render it to HTML
|
||
|
stream = template.generate(**response_args)
|
||
|
response_body = stream.render('html', doctype='html')
|
||
|
response_body = stream.render('html', doctype='html', encoding='utf-8')
|
||
|
|
||
|
# Set the appropriate response headers
|
||
|
response_headers = [('Content-Type', 'text/html'),
|
||
|
response_headers = [('Content-Type', 'text/html; charset=utf-8'),
|
||
|
('Content-Length', str(len(response_body)))]
|
||
|
|
||
|
elif environ['PATH_INFO'].startswith('/day/'):
|
||
| ... | ... | |
|
|
||
|
# Generate the stream and then render it to HTML
|
||
|
stream = template.generate(**response_args)
|
||
|
response_body = stream.render('html', doctype='html')
|
||
|
response_body = stream.render('html', doctype='html', encoding='utf-8')
|
||
|
|
||
|
# Set the appropriate response headers
|
||
|
response_headers = [('Content-Type', 'text/html'),
|
||
|
response_headers = [('Content-Type', 'text/html; charset=utf-8'),
|
||
|
('Content-Length', str(len(response_body)))]
|
||
|
else:
|
||
|
# User supplied an invalid URL
|
||
| ... | ... | |
|
|
||
|
# Return the response body. (Notice it is wrapped in a list although it
|
||
|
# could be any iterable.)
|
||
|
return [response_body]
|
||
|
return [response_body]
|
||
Adding some charset info to make sure mod_wsgi doesn't puke on UTF-8 encoded strings. Also added a "-d" (debug enable) switch to the RPi client so that it only prints out debug information if you want it to. Finally, I added a try except block around the database insert code in the server daemon so that the whole daemone doesn't crash when there is an error.