Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask is not running when Debug is True on Windows #5432

Closed
Ambitiont109 opened this issue Mar 6, 2024 · 1 comment
Closed

Flask is not running when Debug is True on Windows #5432

Ambitiont109 opened this issue Mar 6, 2024 · 1 comment

Comments

@Ambitiont109
Copy link

from flask import Flask
app = Flask(__name__)
if __name__ == "__main__":	
	app.run(debug=True)

I made main.py like above.
and tried to run it with below command
flask run --app test --debug
python main.py
both way got the error like below

image

Traceback (most recent call last): File "D:\Employer\Security Snares\ransomsnare-backend\flask\test.py", line 4, in <module> app.run(debug=True) File "D:\Employer\Security Snares\vee\lib\site-packages\flask\app.py", line 615, in run run_simple(t.cast(str, host), port, self, **options) File "D:\Employer\Security Snares\vee\lib\site-packages\werkzeug\serving.py", line 1077, in run_simple srv = make_server( File "D:\Employer\Security Snares\vee\lib\site-packages\werkzeug\serving.py", line 917, in make_server return ThreadedWSGIServer( File "D:\Employer\Security Snares\vee\lib\site-packages\werkzeug\serving.py", line 779, in __init__ self.socket = socket.fromfd(fd, address_family, socket.SOCK_STREAM) File "C:\Users\K_Teacher\AppData\Local\Programs\Python\Python310\lib\socket.py", line 545, in fromfd nfd = dup(fd) OSError: [WinError 10038] An operation was attempted on something that is not a socket

Environment:

  • Python version: 3.10
  • Flask version: 2.3.2, 3.0.2
  • OS: Windows 10
@davidism
Copy link
Member

davidism commented Mar 6, 2024

As with previous reported incidences of this, I cannot reproduce this issue with the information provided. The dev server reloader tests pass on Windows in CI. When I run a project locally it works as expected as well. It is impossible for me to identify the issue or evaluate a proposed fix if I don't have a reproducing example to test against.

> mkdir example
> cd example
> py -3.12 -m venv .venv
> .venv\Scripts\activate
> pip install flask
# example.py
from flask import Flask

app = Flask(__name__)

@app.route("/")
def index():
    return "Hello, World!"
> flask -A example run --debug
 * Serving Flask app 'example'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Runnning on http://127.0.0.1:5000
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 123-456-789
127.0.0.1 - - [06/Mar/2024 11:44:09] "GET / HTTP/1.1" 200 -
 * Detected change in 'C:\\Users\\David\\Projects\\example\\example.py', reloading
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 123-456-789

@davidism davidism closed this as completed Mar 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants