_1 simple web development framework based on Flask, configuration, debug mode

A configured debug mode

1, the new project flask

Here Insert Picture Description
Open File-New Project to create a project selection Flask
loads created after a period of time (Flask import library)

2, Hello World initial interface

The initial interface is a Hello World! The output interface

Cultural codes, or a little meaning, at least read so many years, again, want to laugh
click the Run button in the upper right corner you can directly run
Here Insert Picture Description
after loading the good in the command line will have the following information
click on the link below 127.0.0.1:5000 you can open the page
127.0.0.1 is sent to address this opportunity, test dedicated 5000 number for the port
Here Insert Picture Description
open in your default browser
Here Insert Picture Description
began as a default browser to open, if you want to change the way open, can lower Seetting-Tools-Web Browswers change inside the default is the system default browser (Setting shortcut is Ctrl + Alt + S)
Here Insert Picture Description

3, change the debug mode (Debug Mode)

You can see the command line start code, there are identified as follows:
mean debug mode is not close (off by default)
Here Insert Picture Description
we are going to turn on debug mode:
added at the bottom of the simulation program entry: Debug = True, as follows

if __name__ == '__main__':
    app.run(Debug=True)

If you immediately re-run it again;
you will find still closed:
Here Insert Picture Description
Do not worry, it is because you have not set up inside the Edit:
Click on Edit COnfigurations the upper right corner
Here Insert Picture Description
on the Debug Mode tick, do not forget to click Apply:
Here Insert Picture Description
Click again run:
Here Insert Picture Description
we will find the open Debug Mode display:
Here Insert Picture Description

  • Debug Mode意义
    那么估计早就有人吐槽了,打开这个模式有什么用:
    打开这个模式的意义在于:
    • 如果你没有打开:
      你在没有打开的情况下,每次更改一次代码,你都需要保存Ctrl+s,然后点击重新运行按钮,他还会弹出一个提示框,你点击确定之后,他才会重新运行,然后命令行里才会出现新的回送地址:127.0.01 ,点击回送地址,然后才能得到你更新之后的运行界面。
      哇,听着都烦。
    • 但是,如果你打开了Debug 模式:
      你打开了Debug 模式,那么当你每次更改完代码之后,只需要按一下保存快捷键Ctrl+S(这个我相信大多数人已经习惯了,对我而言,这是我双手脱离键盘之前比作的一个操作,因为太多血泪的教训了),按下之后,就会自动重新运行,相当于别的IDE中的Make操作(局部更新),然后你只需要点击命令行中的回送链接就能看到你更改之后界面。
      或者你不想在测试的时候每次都打开一个新的web标签:比如下图,每次点击回送地址,都会打开一个新的Tag,多了之后就很烦。
      Here Insert Picture Description
      你可以点击界面上的刷新按钮,既可以得到更改之后的运行界面了。
    • Note:
      Sometimes you will find the change refreshing finish .css file is useless, because the browser refresh command most of the contents of Html files when loading web pages, and css stylesheets are cached in the browser, such css cache as if not updated, because he was too lazy to download it again (in fact not lazy, because the download css stylesheets will take up too much time, the slow refresh, with the first time you open a web page the same), so if you are early in web development, discovery changed the css styles, and web style but how are not updated, may wish to clean up your browser's cache, so the page will re-import css stylesheets after you update.
      Or, most simply, open the browser's developer mode (I use Chrome, the shortcut key is Ctrl + Shift + I), then click on refresh, the page will be updated with even css stylesheets.

Guess you like

Origin blog.csdn.net/qq_37937830/article/details/91459766