Issue
I was running a flask app at http://127.0.0.1:7000/ with the command py main.py
. In my file, the last line is app.run(debug=True, port=7000)
. I have declared the app = Flask(__name__)
. I need the server to restart each time. But the server reloads for unwanted files, and does not allow me to view the page even! The log is:
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
but, I am working with the file at dir: F:\flask-app\app-1\main.py
, with the folder F:\flask-app\app-1
folder open in my VS code. I just want the flask to reload when I make changes in the files present in the folder: F:\flask-app\app-1
and not any other files! Is there any way? Some specifications:
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.
I am using Windows 32-bit.
Solution
This is somewhat odd behaviour but I think it might be because you are using the global python interpreter. I would recommend creating a virtual environment like
python -m venv env
and then
.\env\Scripts\activate
and then install all the packages there and try running flask again.
Answered By - Debdut Goswami
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.