Website back end Python+flask. Flask Debug Mode Open Debug and pin use?
Auto Load:
# Way One
12 |
if __name__ = = ‘__main__‘ : app.run(host = ‘0.0.0.0‘ , port = 9000 , debug = True ) |
# Way Two
123 |
if __name__ = = ' __main__ ' : app.debug = true app.run (host = ' 0.0.0.0 ' , port = 9000 ) |
Note: The debug mode can be opened in two ways, debugging mode, the Py file will be modified automatically reload, resource file/template file/profile modification must be restarted effective ~ This really wood has a way ~
Exception Debugging:
# code Area
123456789101112131415161718 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
#
# Authors: limanman
# 51CTOBG: http://xmdevops.blog.51cto.com/
# Purpose:
#
"""
# 说明: 导入公共模块
from
flask
import
Flask
# 说明: 导入其它模块
app
=
Flask(__name__)
@app
.route(
‘/‘
)
def
hello_word():
return None
if
__name__
=
=
‘__main__‘
:
app.run(host
=
‘0.0.0.0‘
, port
=
9000
, debug
=
True
)
|
# display Area
1234 |
* Restarting with stat * Debugger is active! * Debugger pin code: 160-043-266 * Running on http://0.0.0.0:9000/ (Press CTRL+C to quit) |
# Debug Area
Note: When the error occurs, it automatically returns a debug interface that can get the error context and executable code, WERKZEUG for security, a random pin private authentication code will be generated at startup, and the pin will be forced to enter the wrong stack mode the first time the debugger is started. Werkzeug will then store it in a cookie for a 8-hour expiration time.
Reference:
1, http://blog.51cto.com/xmdevops/1865636
Flask debug mode, Web input PIN code for debugging