Create web app blueprint with Flask

This commit is contained in:
coolneng 2020-06-12 20:03:25 +02:00
parent a20dab0053
commit e83f7a0271
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
8 changed files with 104 additions and 2 deletions

View File

@ -0,0 +1,8 @@
from flask import Flask
from constants import SECRET_KEY
from flask_bootstrap import Bootstrap
app = Flask(__name__)
app.secret_key = SECRET_KEY
bootstrap = Bootstrap(app)

14
app/routes.py Normal file
View File

@ -0,0 +1,14 @@
from flask import render_template
from app import app
@app.route("/")
@app.route("/index")
def index():
return render_template("index.html", title="Home Page")
@app.route("/data")
def data():
return render_template("data.html", title="Data")

12
app/static/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

43
app/templates/base.html Normal file
View File

@ -0,0 +1,43 @@
{% extends 'bootstrap/base.html' %}
{% block title %}
{% if title %}{{ title }} - graphPaname{% else %}graphPaname{% endif %}
{% endblock %}
{% block styles %}
<link rel="stylesheet"
href="{{url_for('.static', filename='bootstrap.min.css')}}">
{% endblock %}
{% block navbar %}
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="{{ url_for('index') }}">graphPaname</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="{{ url_for('index') }}">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-link"><a href="{{ url_for('data') }}">Data</a></li>
</ul>
</div>
</nav>
{% endblock %}
{% block content %}
<div class="container">
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-info" role="alert">{{ message }}</div>
{% endfor %}
{% endif %}
{% endwith %}
{# application content needs to be provided in the app_content block #}
{% block app_content %}{% endblock %}
</div>
{% endblock %}

15
app/templates/data.html Normal file
View File

@ -0,0 +1,15 @@
{% extends "base.html" %}
{% block content %}
<h1 class="text-center">How you like your data?</h1>
<li>
<p class="text-center">
<a href="{{ url_for('map_view') }}" class="btn btn-success" role="button" aria-pressed="true">Maps</a>
</p>
</li>
<li>
<p class="text-center">
<a href="{{ url_for('plot_view') }}" class="btn btn-success" role="button" aria-pressed="true">Plots</a>
</p>
</li>
{% endblock %}

8
app/templates/index.html Normal file
View File

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block content %}
<div class="jumbotron">
<h1 id="graphPaname">graphPaname</h1>
<p>graphPaname is an information system that aims to show real-time data, related to the COVID-19 outbreak, in the city of Paris</p>
</div>
{% endblock %}

View File

@ -38,3 +38,4 @@ COLUMNS = {
"fields.mail", "fields.mail",
], ],
} }
SECRET_KEY = "trolaso"

View File

@ -7,8 +7,9 @@ pkgs.mkShell {
# Dependencies # Dependencies
pandas pandas
requests requests
starlette flask
altair flask-bootstrap
flask_wtf
folium folium
pytest pytest
# Development tools # Development tools