Both your routes are the same? I’m assuming lakas should be its own page so you should change @app.route(‘/’) to @app.route(‘/lakas’)
@app.route('/')
def home():
template_table = {
'title': "Home Control System"
}
return render_template('home.html', **template_table)
@app.route('/')
def lakas():
return render_template('lakas.html')
Change the url in home.html to <a href="{{ url_for('lakas') }}">Lakás</a>
I think you might be having trouble understanding routes. An understanding of MVC might help.
I’m new to html, i have researched a lot, but cannot solve this issue. I’m sure for you it is trivial, but I stuck.
So
I have a flask webserver. that is the code:
it is so simple, just loading the home.html and I guess the issue will be here somewhere, but I cannot find it.
all html docs are in the same folder, in the templates. the home.html loading nicely, but nothing other. I mean if I change in the return render_template the html it will be loaded, but not throug the webpage by clicking.
from flask import Flask, render_template
app = Flask(__name__, template_folder='templates')
@app.route('/')
def home():
template_table = {
'title': "Home Control System"
}
return render_template('home.html', **template_table)
@app.route('/')
def lakas():
return render_template('lakas.html')
if __name__=='__main__':
app.run(debug=True, host='0.0.0.0')
this is the home.html code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
<link rel="stylesheet" type="text/css" href="../static/css/style.css?version=15">
<script type="text/javascript" src="../static/js/scripts.js?version=2"></script>
</head>
<body onload="renderTime()">
<div class="wrapper">
<div style="font-size: 1.5em", style="font-weight: bold">Menü</div>
<div class="nested_1">
<div align="right">Home Control System</div>
<div id="clockDisplay" align="right"></div>
</div>
<div class="nested_2">
<a href="overview.html" target="targetframe">Főoldal</a>
<a href="lakas.html" target="targetframe">Lakás</a>
<a href="garazs.html" target="targetframe">Garázs</a>
</div>
<iframe src="overview.html" name="targetframe" allowTransparency="true" scrolling="no" frameborder="0"></iframe>
</div>
</body>
</html>
the folder structure is:
main
static
templates
home.html
lakas.html
garazs.html
and if I simple open the home.html everything works perfectly, I can click on the buttons(Főoldal, Lakás, Garázs)
but, when I run the flask app and I reach that through the IP I have the home page, but 404 for the rest of them. I attach picture about the ok screen and the 404.
Not found screen
OK screen
What should I change? Could you help me please?