I am new to Flask (and quite new to python) and I have tried running the following very basic script:
from flask import Flask
app= Flask(__name__)
@app.route('/')
def home():
return "This is the homepage"
if __name__=="__main__":
app.run(debug=True)
I am using Python 3.6 and IDLE on Windows 10. The problem is I keep getting the following error:
Traceback (most recent call last):
File "C:/Users/Susy/Desktop/provaflask.py", line 7, in <module>
app.run(debug=True)
File "C:\Users\Susy\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 936, in run
cli.show_server_banner(self.env, self.debug, self.name, False)
File "C:\Users\Susy\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\cli.py", line 630, in show_server_banner
click.echo(message)
File "C:\Users\Susy\AppData\Local\Programs\Python\Python36\lib\site-packages\click\utils.py", line 217, in echo
file = _default_text_stdout()
File "C:\Users\Susy\AppData\Local\Programs\Python\Python36\lib\site-packages\click\_compat.py", line 621, in func
rv = wrapper_func()
File "C:\Users\Susy\AppData\Local\Programs\Python\Python36\lib\site-packages\click\_compat.py", line 385, in get_text_stdout
rv = _get_windows_console_stream(sys.stdout, encoding, errors)
File "C:\Users\Susy\AppData\Local\Programs\Python\Python36\lib\site-packages\click\_winconsole.py", line 261, in _get_windows_console_stream
func = _stream_factories.get(f.fileno())
io.UnsupportedOperation: fileno
From this question, the problem seems to be related to the use of IDLE, however I would like to keep using it, so can you please help? Thank you!
As you can find out here You have to run your script from straight up Python instead.
You have to save that file for example in app.py
and run from your command line:
python app.py
or in your exmaple:
python C:/Users/Susy/Desktop/provaflask.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With