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

Published on Aug. 22, 2023, 12:13 p.m.

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.