Commit fd4f5fd1 authored by Ernesto Crespo's avatar Ernesto Crespo

Articulo 2

parent 20dcb30a
......@@ -2,4 +2,3 @@ from flask import Flask
app = Flask(__name__)
from app import views
{% if title %}
<title>{{ title }} - microblog</title>
{% else %}
{% endif %}
<div>Microblog: <a href="/index">Home</a></div>
{% block content %}{% endblock %}
{% extends "base.html" %}
{% block content %}
<h1>Hola, {{ usuario.nickname }}!</h1>
{% for post in posts %}
{{ post.autor.nickname }} dice: <b>{{ post.cuerpo }}</b>
{% endfor %}
{% endblock %}
#!/usr/bin/env python
#Se importa render_template para renderizar plantillas html
from flask import render_template
#Se importa la aplicacion
from app import app
def hola_nombre(nombre):
return "Hola {}!".format(nombre)
#Se define la ruta del url raiz e index
def hola():
return "Hola mundo!"
def index():
#Se define el nombre del usuario
usuario = {'nickname': 'Ernesto'}
#Se define los posts del blog
posts = [
'autor': {'nickname': 'John Doe'},
'cuerpo': 'Un dia en Edimburgo'
'autor': {'nickname': 'Jane Doe'},
'cuerpo': 'Muy buena Civil war!'
#Se devuelve index.html con el titulo, usuario y posts
return render_template("index.html",
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment