我正在学习一些关于HTTP协议的知识,并试图用Python编写一个基本的WSGI应用程序。我安装了gunicorn
WSGI服务器,并获得了一个基本的“helloworld”来工作
但是,我仍然想知道如何在页面上显示实际的HTML。也就是说,如何在响应中包含HTML
例如:
def app(environ, start_response):
"""Simplest possible application object"""
data = b'<html> Hello, World!\n </html>'
status = '200 OK'
response_headers = [
('Content-type','text/plain'),
('Content-Length', str(len(data)))
]
start_response(status, response_headers)
return iter([data])
目前没有回答
相关问题 更多 >
编程相关推荐