Add Flask webapp draft
This commit is contained in:
5
code/app/__init__.py
Normal file
5
code/app/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
from app import routes
|
||||
13
code/app/routes.py
Normal file
13
code/app/routes.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from app import app
|
||||
from flask import render_template
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@app.route("/index")
|
||||
def index():
|
||||
user = {"username": "Bolaji"}
|
||||
posts = [
|
||||
{"author": {"username": "Miloud"}, "body": "Beautiful day in Meknes!"},
|
||||
{"author": {"username": "Sebtaoui"}, "body": "The Farkouss movie was lit!"},
|
||||
]
|
||||
return render_template("index.html", title="Home", user=user, posts=posts)
|
||||
14
code/app/templates/base.html
Normal file
14
code/app/templates/base.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<head>
|
||||
{% if title %}
|
||||
<title>{{ title }} - IGDB</title>
|
||||
{% else %}
|
||||
<title>Welcome to IGDB</title>
|
||||
{% endif %}
|
||||
</head>
|
||||
<body>
|
||||
<div>IGDB: <a href="/index">Home</a></div>
|
||||
<hr>
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
8
code/app/templates/index.html
Normal file
8
code/app/templates/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Hi, {{ 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