Python 防止烧瓶app';从不需要的重新加载中删除开发服务器

Python 防止烧瓶app';从不需要的重新加载中删除开发服务器,python,flask,reload,web-development-server,Python,Flask,Reload,Web Development Server,我用命令pymain.py在运行一个flask应用程序。在我的文件中,最后一行是app.run(debug=True,port=7000)。我已经声明了app=Flask(\uuuuu name\uuuuuu)。我需要服务器每次重新启动。但是服务器会重新加载不需要的文件,甚至不允许我查看页面!日志是: F:\Github SPRINGREEN\web-app>py main.py * Serving Flask app "main" (lazy loading) *

我用命令
pymain.py
在运行一个flask应用程序。在我的文件中,最后一行是app.run(debug=True,port=7000)。我已经声明了
app=Flask(\uuuuu name\uuuuuu)
。我需要服务器每次重新启动。但是服务器会重新加载不需要的文件,甚至不允许我查看页面!日志是:

F:\Github SPRINGREEN\web-app>py main.py
 * Serving Flask app "main" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with windowsapi reloader
 * Debugger is active!
 * Debugger PIN: 140-651-644
 * Running on http://127.0.0.1:7000/ (Press CTRL+C to quit)
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\toml\\encoder.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\toml\\ordered.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\toml\\tz.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\toml\\__init__.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\urllib3\\connection.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\urllib3\\connectionpool.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\urllib3\\exceptions.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\urllib3\\fields.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\urllib3\\filepost.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pip\\_vendor\\urllib3\\poolmanager.py', reloading
 * Restarting with windowsapi reloader
 * Debugger is active!
 * Debugger PIN: 140-651-644
 * Running on http://127.0.0.1:7000/ (Press CTRL+C to quit)
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32comgenpy.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\__init__.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\lib\\modulegraph\\find_modules.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\lib\\modulegraph\\modulegraph.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\lib\\modulegraph\\util.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\lib\\modulegraph\\zipio.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\lib\\modulegraph\\_compat.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\lib\\modulegraph\\__init__.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\lib\\modulegraph\\__main__.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\utils\\cliutils\\archive_viewer.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\utils\\cliutils\\bindepend.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\utils\\cliutils\\grab_version.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\utils\\cliutils\\makespec.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\utils\\cliutils\\set_version.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\utils\\cliutils\\__init__.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\PyInstaller\\utils\\hooks\\django.py', reloading
 * Restarting with windowsapi reloader
 * Debugger is active!
 * Debugger PIN: 140-651-644
 * Running on http://127.0.0.1:7000/ (Press CTRL+C to quit)
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\advanced\\resolve_peer.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\advanced\\save_file.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\advanced\\send.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\advanced\\__init__.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\auth\\accept_terms_of_service.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\auth\\check_password.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\auth\\connect.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\auth\\disconnect.py', reloading
 * Restarting with windowsapi reloader
 * Debugger is active!
 * Debugger PIN: 140-651-644
 * Running on http://127.0.0.1:7000/ (Press CTRL+C to quit)
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\leave_chat.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\mark_chat_unread.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\pin_chat_message.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\promote_chat_member.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\restrict_chat_member.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\set_administrator_title.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\set_chat_description.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\set_chat_permissions.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\set_chat_photo.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\set_chat_title.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\set_slow_mode.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\unarchive_chats.py', reloading
 * Detected change in 'C:\\Users\\new\\AppData\\Local\\Programs\\Python\\Python39-32\\Lib\\site-packages\\pyrogram\\methods\\chats\\unban_chat_member.py', reloading
但是,我正在使用dir:
F:\flask app\app-1\main.py
上的文件,在我的VS代码中打开文件夹
F:\flask app\app-1
。我只想在更改文件夹中的文件时重新加载烧瓶:
F:\flask app\app-1
,而不是任何其他文件!有办法吗?一些规格:


C:\User\new>python -V
Python 3.9.1

C:\User\new>python -m flask --version
Python 3.9.1
Flask 1.1.2
Werkzeug 1.0.1

C:\User\new>cmd
Microsoft Windows [Version 10.0.19042.985]
(c) Microsoft Corporation. All rights reserved.


我使用的是Windows 32位。

这有点奇怪,但我认为可能是因为您使用的是全局python解释器。我建议创建一个虚拟环境,如
python-m venv env
然后
\env\Scripts\activate


然后在那里安装所有软件包并再次尝试运行flask。

我没想到VENV会帮我!谢谢,这对我来说很有效。这对我来说甚至有些出乎意料。我不使用windows,但我认为可能是这样。不管怎样,很高兴它成功了。