python · 1月 21, 2023 0

How to run the flask application on Port 8001, which is already occupied

内容纲要

The standard port for the Flask application is 5000.So we can access our application.

http://127.0.0.1:5000/

We may want to change the port is already occupied.We can use the below command to run the Flask application .

if __name__ == ‘__main__’:    
   app.run(debug=True, port=port_number)
# helloworld.py
# import flask module
from flask import Flask

# instance of flask application
app = Flask(__name__)

# home route that returns below text
# when root url is accessed
@app.route("/")
def hello_world():
    return "Hello, World!"

if __name__ == '__main__':
    app.run(debug=True, port=8001)

We are running the application of the flask Application on Port 8001.

%d 博主赞过: