5

Instead of using send_static_file, I want to use something like html('<h1>content</h1>'), sort of like jsonify.

@app.route('/incorrect_pass')
def incorrect_pass():
    return html('Incorrect password. <a href="/">Go back?</a>')

Is what I want to do.

2 Answers2

5

Never mind. Should've checked. Flask returns strings as html, so the html() isn't necessary above.

1

Why not just:

def html(content):  # Also allows you to set your own <head></head> etc
   return '<html><head>custom head stuff here</head><body>' + content + '</body></html>'

@app.route('/incorrect_pass')
def incorrect_pass():
    return html('Incorrect password. <a href="/">Go back?</a>')
    # OR return  'Incorrect password. <a href="/">Go back?</a>
alexisdevarennes
  • 5,437
  • 4
  • 24
  • 38