一个完整的web应用:服务器收到来自浏览器的一个请求,服务器将请求内容的网页返回给浏览器,让浏览器显示出来。【而浏览器与服务器之前的传输协议是HTTP】
http:是网络上传输html的协议,用于浏览器与服务器的通信。
html:是一种定义网页的文本。
常见的状态码!
200
404 服务器无法根据客户端的请求找到资源(网页)。通过此代码,网站设计人员可设置"您所请求的资源无法找到"的个性页面
500 Internal Server Error 服务器内部错误,无法完成请求
WSGI:web server gateway interface【web服务器网关接口】
原理:要求web开发者实现一个函数,就可以响应http请求。
例子:
def application(environ , start_response):
start_response(‘200 ok‘,[(‘Content-Type‘,‘text/html‘)])
return ‘<h1>hello ,web</h1>‘
environ: 一个包含所有http请求信息dict对象
start_response:一个发送http响应的函数
在application()函数中:调用:
start_response(‘200 ok‘,[(‘Content-Type‘,‘text/html‘)])
原文:https://www.cnblogs.com/1314520xh/p/11621096.html