0

I have two flask apps running on local host and different port, 5000 and 5001. first i'm running the flask app on port 5000 and then if my condition of flask app 1 satisfies , i want to redirect it to index.html running on port number 5001.

i have tried return render_template('http://localhost:5001/index.html') but it gives an error jinja2.exceptions.TemplateNotFound: http://localhost:5001/index.html

1 Answers1

2

this error is because you can't render another app's template, for redirecting in this condition you can act like below, it's my flask app that simply show how to redirect between apps

from flask import Flask,redirect
app = Flask(__name__)

@app.route("/")
def test():
    return redirect('http://localhost:5001', code=301)
Pythoscorpion
  • 166
  • 1
  • 10