From c29b1b18612a87ee9cbf562337eff06bb73be3f0 Mon Sep 17 00:00:00 2001 From: Simon Milvert Date: Fri, 25 Aug 2017 16:05:12 +0200 Subject: [PATCH] Add a template with static page --- .gitignore | 1 + app/__init__.py | 7 +- app/site/__init__.py | 4 ++ app/site/views.py | 32 +++++++++ app/static/css/style.css | 125 ++++++++++++++++++++++++++++++++++ app/templates/base.html | 51 ++++++++++++++ app/templates/site/index.html | 19 ++++++ 7 files changed, 234 insertions(+), 5 deletions(-) create mode 100644 app/site/__init__.py create mode 100644 app/site/views.py create mode 100644 app/static/css/style.css create mode 100644 app/templates/base.html create mode 100644 app/templates/site/index.html diff --git a/.gitignore b/.gitignore index 7f7cccc..479cd3f 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ var/ *.egg-info/ .installed.cfg *.egg +.ropeproject/ # PyInstaller # Usually these files are written by a python script from a template diff --git a/app/__init__.py b/app/__init__.py index 4bf2b0c..6be6022 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -15,11 +15,8 @@ def create_app(config_name): from app import models from .api import api as api_blueprint + from .site import site as site_blueprint app.register_blueprint(api_blueprint) - - - @app.route('/') - def hello_world(): - return 'Hello, World!' + app.register_blueprint(site_blueprint) return app diff --git a/app/site/__init__.py b/app/site/__init__.py new file mode 100644 index 0000000..065bc99 --- /dev/null +++ b/app/site/__init__.py @@ -0,0 +1,4 @@ +from flask import Blueprint + +site = Blueprint('site', __name__) +from . import views diff --git a/app/site/views.py b/app/site/views.py new file mode 100644 index 0000000..8739011 --- /dev/null +++ b/app/site/views.py @@ -0,0 +1,32 @@ +from flask import abort, render_template +from flask_login import current_user, login_required + +from . import site + + +@site.route('/') +def homepage(): + """ + Render the homepage template on the / route + """ + return render_template('site/index.html', title="Welcome") + + +@site.route('/dashboard') +@login_required +def dashboard(): + """ + Render the dashboard template on the /dashboard route + """ + return render_template('home/dashboard.html', title="Dashboard") + + +@site.route('/admin/dashboard') +@login_required +def admin_dashboard(): + # prevent non-admins from accessing the page + if not current_user.is_admin: + abort(403) + + return render_template('home/admin_dashboard.html', title="Dashboard") + diff --git a/app/static/css/style.css b/app/static/css/style.css new file mode 100644 index 0000000..b14efdb --- /dev/null +++ b/app/static/css/style.css @@ -0,0 +1,125 @@ +body, html { + width: 100%; + height: 100%; +} + +body, h1, h2, h3 { + font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight: 700; +} + +a, .navbar-default .navbar-brand, .navbar-default .navbar-nav>li>a { + color: #aec251; +} + +a:hover, .navbar-default .navbar-brand:hover, .navbar-default .navbar-nav>li>a:hover { + color: #687430; +} + +footer { + padding: 50px 0; + background-color: #f8f8f8; +} + +p.copyright { + margin: 15px 0 0; +} + +.alert-info { + width: 50%; + margin: auto; + color: #687430; + background-color: #e6ecca; + border-color: #aec251; +} + +.btn-default { + border-color: #aec251; + color: #aec251; +} + +.btn-default:hover { + background-color: #aec251; +} + +.center { + margin: auto; + width: 50%; + padding: 10px; +} + +.content-section { + padding: 50px 0; + border-top: 1px solid #e7e7e7; +} + +.footer, .push { + clear: both; + height: 4em; +} + +.intro-divider { + width: 400px; + border-top: 1px solid #f8f8f8; + border-bottom: 1px solid rgba(0,0,0,0.2); +} + +.intro-header { + padding-top: 50px; + padding-bottom: 50px; + text-align: center; + color: #f8f8f8; + background: url(../img/intro-bg.jpg) no-repeat center center; + background-size: cover; + height: 100%; +} + +.intro-message { + position: relative; + padding-top: 20%; + padding-bottom: 20%; +} + +.intro-message > h1 { + margin: 0; + text-shadow: 2px 2px 3px rgba(0,0,0,0.6); + font-size: 5em; +} + +.intro-message > h3 { + text-shadow: 2px 2px 3px rgba(0,0,0,0.6); +} + +.lead { + font-size: 18px; + font-weight: 400; +} + +.topnav { + font-size: 14px; +} + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -4em; +} + +.outer { + display: table; + position: absolute; + height: 70%; + width: 100%; +} + +.middle { + display: table-cell; + vertical-align: middle; +} + +.inner { + margin-left: auto; + margin-right: auto; +} + diff --git a/app/templates/base.html b/app/templates/base.html new file mode 100644 index 0000000..74edded --- /dev/null +++ b/app/templates/base.html @@ -0,0 +1,51 @@ + + + + {{ title }} | Project Dream Team + + + + + + + +
+ {% block body %} + {% endblock %} +
+
+ + + + + diff --git a/app/templates/site/index.html b/app/templates/site/index.html new file mode 100644 index 0000000..690e1ef --- /dev/null +++ b/app/templates/site/index.html @@ -0,0 +1,19 @@ +{% extends "base.html" %} +{% block title %}Home{% endblock %} +{% block body %} +
+
+
+
+
+

Project Dream Team

+

Hello world!

+
+ +
+
+
+
+
+{% endblock %} +