flask html code example
Example 1: python flask
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hello world!"
if __name__ == '__main__':
app.debug = True
app.run()
Example 2: python render_template
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template("index.html")
if __name__ == '__main__':
app.debug = True
app.run()
Example 3: how do you render a template in flask
return render_template("home.html")
Example 4: flask form
class PostForm(FlaskForm):
title = StringField('Title', validators=[DataRequired()])
content = TextAreaField('Content', validators=[DataRequired()])
validators=[DataRequired(), Length(min=2, max=50)])
submit = SubmitField('Post')