I am new to Python web frameworks and am trying to learn Flask. I went through a textbook and everything was fine. Now I am trying to make my own application to study the structure. I had the following code in the main.py file
@app.route('/') def index(): return render_template('main.html')
In main.html I have this html
{% extends "layout.html" %} {% block content %} <div> Foo bar test</div> {% endblock %}
and then in layout.html I have a basic web layout that looks like
<!DOCTYPE html> <title>Flaskpad</title> <link href="/static/css/bootstrap.css" rel="stylesheet"> <link href="/static/css/flaskpad.css" rel="stylesheet"> <style type="text/css"> .socials { padding: 10px; } </style> </head> <body> <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <ul class="nav"> <li class="active"> <a class="brand" href="#">Flaskpad/a> </li> <li><a href="#">Login</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </div> </div> </div> <div class="container"> <div class="row fcontent"> <div class="span3"> Empty Space </div> <div class="span6 maincontent"> {% block content %}{% endblock %} </div> <div class="span3"> Empty Space </div> </div> <div class="row ffooter"> <div class="span12"> Made by Bar Foo </div> </div> </div> </body>
I know that css links do not execute correctly, but I just put them there as placeholders. Now when I run python flask.py and switch to localhost: 5000, the page becomes blank and I cannot understand why. If I put plain text in main.html before the extension to be displayed, so I know that it loads main.html, but doesn't seem to extend the layout. The page is literally empty, because when viewing the source there is nothing. I canβt figure it out.
source share