write with Flask. When you get to the front end of the render_template () data page, you suddenly start to report dead errors. No matter how you adjust the back end, it is useless. Which god helps to find out the reason, thank you
report error:
:"index.html"
{% extends "base.html" %}
{% extends "bootstrap/wtf.html" as wtf %}
{% block title %} Hello {% endblock %}
{% block page_content %}
<div class="page-header">
<h1>Hello,{% if name %}{{ name }}{% else %}Stranger{% endif %}!</h1>
</div>
{{ wtf.quick_form(form) }}
{% endblock %}
backend file: "Hello.py"
from flask import Flask
from flask import render_template
from flask_bootstrap import Bootstrap
from flask_moment import Moment
-sharp from datetime import datetime
-sharp from flask import abort
from flask_script import Manager
from flask_wtf import Form
from wtforms import StringField,SubmitField
from wtforms.validators import DataRequired
app = Flask(__name__)
app.config["SECRET_KEY"] = "hard to guess string" -sharpFlask-WTF
manager = Manager(app)
bootstrap = Bootstrap(app) -sharpFlask-Boorstrap
moment = Moment(app) -sharpFlask-Moment
-sharp
class NameForm(Form):
name = StringField("What is your name?",validators=[DataRequired()])
submit = SubmitField("Submit")
@app.errorhandler(404)
def page_not_found(e):
return render_template("404.html"),404
@app.errorhandler(500)
def internal_server_error(e):
return render_template("500.html"),500
@app.route("/",methods = ["GET","POST"])
def index():
name = None
form = NameForm()
if form.validate_on_submit():
name = form.name.data
form.name.data = ""
return render_template("index.html")
if __name__ == "__main__":
-sharp app.run(host = "0.0.0.0")
app.run(debug = True)