templates
This commit is contained in:
		
							parent
							
								
									79e9810b62
								
							
						
					
					
						commit
						a1fa2715ad
					
				| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
<html>
 | 
			
		||||
  <head>
 | 
			
		||||
    {% if title %}
 | 
			
		||||
    <title>{{title}} - microblog</title>
 | 
			
		||||
    {% else %}
 | 
			
		||||
    <title>microblog</title>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
  </head>
 | 
			
		||||
  <body>
 | 
			
		||||
    <div>Microblog: <a href="/index">Home</a></div>
 | 
			
		||||
    <hr>
 | 
			
		||||
    {% block content %}{% endblock %}
 | 
			
		||||
  </body>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
{% extends "base.html" %}
 | 
			
		||||
{% block content %}
 | 
			
		||||
<h1>Hi, {{user.nickname}}!</h1>
 | 
			
		||||
{% for post in posts %}
 | 
			
		||||
<p>
 | 
			
		||||
  {{post.author.nickname}} says: <b>{{post.body}}</b>
 | 
			
		||||
</p>
 | 
			
		||||
{% endfor %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
							
								
								
									
										17
									
								
								app/views.py
								
								
								
								
							
							
						
						
									
										17
									
								
								app/views.py
								
								
								
								
							| 
						 | 
				
			
			@ -1,6 +1,21 @@
 | 
			
		|||
from flask import render_template
 | 
			
		||||
from app import app
 | 
			
		||||
 | 
			
		||||
@app.route('/')
 | 
			
		||||
@app.route('/index')
 | 
			
		||||
def index():
 | 
			
		||||
    return "Hello, World!"
 | 
			
		||||
    user = { 'nickname': 'Miguel' }
 | 
			
		||||
    posts = [
 | 
			
		||||
        { 
 | 
			
		||||
            'author': { 'nickname': 'John' }, 
 | 
			
		||||
            'body': 'Beautiful day in Portland!' 
 | 
			
		||||
        },
 | 
			
		||||
        { 
 | 
			
		||||
            'author': { 'nickname': 'Susan' }, 
 | 
			
		||||
            'body': 'The Avengers movie was so cool!' 
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
    return render_template("index.html",
 | 
			
		||||
        title = 'Home',
 | 
			
		||||
        user = user,
 | 
			
		||||
        posts = posts)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue