Flask源码阅读(二)——启动服务器(run方法)
来源:互联网 发布:网络直播平台列表 编辑:程序博客网 时间:2024/05/01 11:31
1.Flask提供的Web服务器不适合在生产环境中使用
2.run方法启动flask集成的服务器:
例:
if __name__ == '__main__': app.run(debug=True)
3.源码:
def run(self, host='localhost', port=5000, **options): """Runs the application on a local development server. If the :attr:`debug` flag is set the server will automatically reload for code changes and show a debugger in case an exception happened. :param host: the hostname to listen on. set this to ``'0.0.0.0'`` to have the server available externally as well. :param port: the port of the webserver :param options: the options to be forwarded to the underlying Werkzeug server. See :func:`werkzeug.run_simple` for more information. """ from werkzeug import run_simple if 'debug' in options: self.debug = options.pop('debug') options.setdefault('use_reloader', self.debug) options.setdefault('use_debugger', self.debug) return run_simple(host, port, self, **options)
从源码中可以看出,Flask集成的run方法是由werkzeug中的run_simple方法提供的。run()接受debug参数时,options.pop('debug')
,设定’use_reloader’默认参数为self.debug,’use_debugger’为self.debug.
4.总结
依赖werkzeug
0 0
- Flask源码阅读(二)——启动服务器(run方法)
- Flask源码阅读(三)——渲染模板
- Flask源码阅读(四)——自定义错误界面
- Flask源码阅读(五)——链接
- Flask源码阅读(六)——Flash消息
- Flask源码阅读(七)——上下文变量
- Flask源码阅读(八)——请求钩子
- Flask源码阅读(九)——响应
- Flask源码阅读(十)——查缺补漏
- machine.run源码阅读记录---流水帐(二)
- Flask源码分析(二)
- flask源码阅读 应用启动流程
- flask源码笔记:三,app.py模块(6)——Flask的方法(上)
- flask源码笔记:三,app.py模块(7)——Flask的方法(下)
- tomcat源码阅读(二)——ClassLoader及catalina启动
- Flask源码阅读(一)——路由和视图函数
- 源码阅读(二)
- Flask 源码阅读笔记
- Maven 私服 Nexus 界面配置
- robomongo 连不上mongodb 权限问题
- C# WinForm中工具栏上如何既显示文字又显示图片
- 百度地图应用:根据两个地址的经纬度求距离;根据地址求经纬度;根据经纬度求地址
- Spark指令
- Flask源码阅读(二)——启动服务器(run方法)
- Qt 就是牛逼 利用connect 函数,对比 OC 的自身代理的方法,巧妙躲过了代理
- 在windows下配置eclipse的spark调试环境
- 浮动工具栏
- const修饰符注意点...
- 小牛电动车的亮点与槽点分析
- core graphics
- 高性能网站架构之缓存篇--Redis安装配置
- 应用程序实例——用户信息管理