Search code examples
pythonflask

Cannot modify port, windows port setting problem


Why I cannot modify FLASK port

#cmd
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit

I used serve or app.run() and set port=5566, always not work

#index.py
if __name__ == "__main__":
    from waitress import serve
    serve(app, host="0.0.0.0", port=5566)
    #app.run()

I set windows11 fire wall input/output rule, all allow, port:5566 ,but system show me didn't open the port:5566

And at server pc type "http://127.0.0.1:5000/" I can upload image by FLASK,server pc can get the image, but will appear "Internal Server Error" lead to I cannot return anything.

Other user type "IP" can connect to website but cannot upload image, type "IP:5000" or "IP:5566", cannot link to website


Solution

  • Try running it from the command line.
    (I mean the windows one not one built in to an editor)
    According to this question, it helped.
    To do this, open a command prompt by pressing WINDOWS + R then typecmd.
    Then type python <yourscript>.py
    Also try running the command promt as an admin.