mg tut c2
This commit is contained in:
		@@ -1,7 +1,22 @@
 | 
				
			|||||||
 | 
					from flask import render_template
 | 
				
			||||||
from app import app
 | 
					from app import app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route('/')
 | 
					@app.route('/')
 | 
				
			||||||
@app.route('/index')
 | 
					@app.route('/index')
 | 
				
			||||||
def index():
 | 
					def index():
 | 
				
			||||||
    return "Hello, World!"
 | 
					
 | 
				
			||||||
 | 
					    user = {'username': 'Finnaa'}
 | 
				
			||||||
 | 
					    posts = [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            'author': {'username': 'john'},
 | 
				
			||||||
 | 
					            'body': 'Beautiful day 1'
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            'author': {'username': 'susie'},
 | 
				
			||||||
 | 
					            'body': 'Movie is good.'
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					    #return posts;
 | 
				
			||||||
 | 
					    return render_template('index.html', title='Home', user=user, posts=posts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								backend/app/templates/base.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								backend/app/templates/base.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					<!doctype html>
 | 
				
			||||||
 | 
					<html>
 | 
				
			||||||
 | 
						<head>
 | 
				
			||||||
 | 
							{% if title %}
 | 
				
			||||||
 | 
							<title>{{ title }} - blog</title>
 | 
				
			||||||
 | 
							{% else %}
 | 
				
			||||||
 | 
							<title>Welcome to blog.</title>
 | 
				
			||||||
 | 
							{% endif %}
 | 
				
			||||||
 | 
						</head>
 | 
				
			||||||
 | 
						<body>
 | 
				
			||||||
 | 
							<div>blgo: <a href="/index">home</a></div>
 | 
				
			||||||
 | 
							<hr>
 | 
				
			||||||
 | 
							{% block content %}{% endblock %}
 | 
				
			||||||
 | 
						</body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										11
									
								
								backend/app/templates/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								backend/app/templates/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					{% extends "base.html" %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% block content %}
 | 
				
			||||||
 | 
						<h1>Helloo, {{ user.username }}!</h1>
 | 
				
			||||||
 | 
						{% for post in posts %}
 | 
				
			||||||
 | 
						<div><p>{{ post.author.username }} says: <b>{{ post.body }}</b></p></div>
 | 
				
			||||||
 | 
						{% endfor %}
 | 
				
			||||||
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Reference in New Issue
	
	Block a user