Flask debug mode, Web input PIN code for debugging

Source: Internet
Author: User
Tags python decorator

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:#"""# 说明: 导入公共模块fromflask importFlask# 说明: 导入其它模块app =Flask(__name__)@app.route(‘/‘)defhello_word():    return Noneif__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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.