Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
Forked from angelabauer/main.py
Last active May 17, 2024 08:33
Show Gist options
  • Save TheMuellenator/29acd670326c6313bc2b8f7e66fd441f to your computer and use it in GitHub Desktop.
Save TheMuellenator/29acd670326c6313bc2b8f7e66fd441f to your computer and use it in GitHub Desktop.
Day 61 L464 - Installing Flask-WTF
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)
@arpy8
Copy link

arpy8 commented May 7, 2023

ImportError: cannot import name 'Markup' from 'jinja2' for me and I cant solve it..

Can any one help me, how to resolve this problem

https://stackoverflow.com/questions/71645272/importerror-cannot-import-name-markup-from-jinja2

this might help you

@parvathyhydro
Copy link

Hi there!

If anyone gets an error while starting the project, just make these changes to requirements.txt

Flask==2.0.3
Jinja2==3.1.1
itsdangerous==2.0.1
flask

@parvathyhydro
Copy link

Thank you so much it help me out .

@Wrinklytech
Copy link

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.

@bahae3
Copy link

bahae3 commented Jun 11, 2023

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

@gureumjigi
Copy link

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!

@inavadeep1205
Copy link

app = Flask(__name__)

@app.route("/")
def login():
    return render_template("login.html")

app.run()

@stevenson007
Copy link

I still have this error message after upgrading the framworks.
Capture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment