Add Flask webapp draft

This commit is contained in:
2020-01-08 05:51:10 +01:00
parent b7e7c3400d
commit 712c84b358
9 changed files with 81 additions and 24 deletions

5
code/app/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
from flask import Flask
app = Flask(__name__)
from app import routes

13
code/app/routes.py Normal file
View 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)

View 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>

View 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 %}