Python Web Development-flask Debug mode

Source: Internet
Author: User
Use the run () mode to start the Flask app, but after each code change, a reboot is required, which is inconvenient for debugging. The debug mode of flask allows the code to be loaded automatically after each modification.

There are two ways to enable debug mode for flask

1. Directly set the app's debug to True:

App.debug=true

2. Pass the debug=true as a parameter to the Run method

App.run (Debug=true)

In the first case, when we set the debug mode, the output of the console window will change accordingly.

Now visit the app's homepage:

Modify the code on the homepage:

@app. Route ("/")
def index ():
return "Index Page with Debug"

After modification, you can see the output of the console window

Then refresh the page directly:

The changes are in effect!

Debug mode is very convenient for debugging the development process, but for security exams, the production environment must not use debug mode.

Python Web Development-flask Debug mode

Related Article

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.