-
-
Save TheMuellenator/29acd670326c6313bc2b8f7e66fd441f to your computer and use it in GitHub Desktop.
from flask import Flask, render_template | |
app = Flask(__name__) | |
@app.route("/") | |
def home(): | |
return render_template('index.html') | |
@app.route("/login") | |
def login(): | |
return render_template("login.html") | |
if __name__ == '__main__': | |
app.run(debug=True) |
so there is a problem with how the login button behave. aperrantly "button" tags dont accept href, to fix this all you neeed to do is to seperate them, like that:
<a href="{{ url_for('login') }}"> <button class="btn btn-primary btn-lg">Login</button> </a> `This works thank you
<button onclick="window.location.href='{{ url_for('login') }}';">Login</button>
This also seems to work.
I received this: from jinja2 import Markup, escape ImportError: cannot import name 'Markup' from 'jinja2'
Tried the methods above but it did not work. What should I do?
Hi,
try this on your terminal: pip install --upgrade flask jinja2
For everyone who suffers from ImportError:
type this code below in your Terminal.
pip install Flask==2.0.3
This worked for me. Good Luck!
app = Flask(__name__)
@app.route("/")
def login():
return render_template("login.html")
app.run()
I still have error on "address already in use and start with a new server port"
For people who see this part in December 2022 and receive error : ImportError: cannot import name 'Markup' from 'jinja2', put below codes inside of requirement.txt. Good luck!.
click==8.0.4 Flask==2.0.3 itsdangerous==2.1.2 Jinja2==3.1.1 MarkupSafe==2.1.1 Werkzeug==2.0.3
Thanks man this works.
Thank you so much it help me out .