python multiple flask on one server

  1. Import necessary modules:
from flask import Flask
  1. Create Flask instances for each application:
app1 = Flask(__name__)
app2 = Flask(__name__)
  1. Define routes for each application:
@app1.route('/app1')
def app1_route():
    return 'Hello from App 1'

@app2.route('/app2')
def app2_route():
    return 'Hello from App 2'
  1. Run each application with different port numbers:
if __name__ == '__main__':
    app1.run(port=5000)
    app2.run(port=5001)
  1. Save the script with a filename (e.g., multiple_apps.py) and run it in the terminal:
python multiple_apps.py
  1. Access each application in a web browser using the specified port numbers:
  2. App 1: http://localhost:5000/app1
  3. App 2: http://localhost:5001/app2