main.py
`from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')`
home.html
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>HOME</h1>
<a href="hello.html">hello</a>
</body>
</html>`
hello.html
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hello</title>
</head>
<body>
<h1>Hello</h1>
</body>
</html>`
home.html is displaying while clicking the address
hello.html is not displaying while clicking the hyper link
2
Answers
Try this code
In main.py: Created new @app.route(‘/hi’) that returns hello.html when called from home.html (see below)
In home.html: Changed href="hello.html" To href="/hi" to call that Flask route:
Flask Code:
home.html:
hello.html:
It looks like you’re missing a route in your main.py file for the hello.html page. You need to add a new route that maps to the URL path /hello.html and returns the hello.html template.