The response we return from a view function is not limited to plain text or data. It can also return HTML to be rendered on a webpage:
@app.route('/') def home(): return '<h1>Hello, World!</h1>'
We can use triple quotes to contain multi-line code:
@app.route('/') @app.route('/home') def home(): return ''' <h1>Hello, World!</h1> <p>My first paragraph.</p> <a href="https://www.codecademy.com">CODECADEMY</a> '''
home() function to return
Hello, World! as a
Run app.py and view your page at http://localhost:5000/ in the browser.
reporter() to return
Reporter Bio as a
Navigate to http://localhost:5000/reporter in the browser.
Let’s add another tag to the HTML in
reporter()! After the
<h2> heading, add an
<a> tag with the text
Return to home page that links back to http://localhost:5000/. To have the code run properly in the learning environment, use just the relative path
"/" as the
Run the app and try clicking on the link you created!