From 247dd7fb916cdd1c98f0aecfc1edbea25a4b923a Mon Sep 17 00:00:00 2001 From: zeroth Date: Thu, 10 Jan 2019 18:17:21 +0000 Subject: [PATCH] adding context stuff --- contextualise.py | 32 ++++++++++++++++++++++++++++++++ startform.py | 2 +- static/css/main.css | 4 ++++ templates/about.html | 10 ++++++++++ templates/description.html | 10 +++++----- templates/home.html | 7 +++++++ templates/layout.html | 25 +++++++++++++++++++++++++ 7 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 contextualise.py create mode 100644 static/css/main.css create mode 100644 templates/about.html create mode 100644 templates/home.html create mode 100644 templates/layout.html diff --git a/contextualise.py b/contextualise.py new file mode 100644 index 0000000..f8f2ece --- /dev/null +++ b/contextualise.py @@ -0,0 +1,32 @@ +from flask import Flask, url_for, render_template, Markup, redirect, request, flash +from flask import session as login_session +from flask_wtf import FlaskForm +from wtforms.validators import DataRequired +from wtforms import Form, TextField, TextAreaField, BooleanField, validators, StringField, SubmitField +from forms import ReusableForm +from config import Config +import json + +app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates") +app.config.from_object(Config) + +@app.route("/") +def home(): + return render_template('home.html') + +@app.route('/about/') +def about(): + return render_template('about.html') + +@app.route('/description/', methods=['GET', 'POST']) +def description(): + form = ReusableForm(request.form) + print (form.errors) + if request.method == 'POST' and form.validate(): + return 'Success' + return render_template('description.html', form=form) + + + +if __name__ == '__main__': + app.run(debug=True) diff --git a/startform.py b/startform.py index cfc63b6..bda0b2d 100644 --- a/startform.py +++ b/startform.py @@ -3,7 +3,6 @@ from flask import Flask, url_for, render_template, Markup, redirect, request, fl from flask import session as login_session from forms import ReusableForm from config import Config - import json app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates") @@ -17,6 +16,7 @@ def description(): if request.method == 'POST' and form.validate(): return 'Success' return render_template('description.html', form=form) + if __name__ == '__main__': app.run(debug = True) diff --git a/static/css/main.css b/static/css/main.css new file mode 100644 index 0000000..c6cc167 --- /dev/null +++ b/static/css/main.css @@ -0,0 +1,4 @@ +body{ + background: lavender; + color:blue; +} \ No newline at end of file diff --git a/templates/about.html b/templates/about.html new file mode 100644 index 0000000..4bcc61b --- /dev/null +++ b/templates/about.html @@ -0,0 +1,10 @@ + + + + {% extends "layout.html" %} + {% block content %} +
+

About me

+

This is a portfolio site about anything that can be put in a portfolio.

+
+ {% endblock %} diff --git a/templates/description.html b/templates/description.html index 66d315d..4a5687d 100644 --- a/templates/description.html +++ b/templates/description.html @@ -1,6 +1,6 @@ - - - +{% extends "layout.html" %} +{% block content %} +

Write something very interesting here.

{% for message in form.name.errors %}
{{ message }}
@@ -16,5 +16,5 @@
{{ form.submit }}
- - \ No newline at end of file +
+ {% endblock %} diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..308dbe0 --- /dev/null +++ b/templates/home.html @@ -0,0 +1,7 @@ +{% extends "layout.html" %} + {% block content %} +
+

THIS IS THE HOME PAGE

+

This website was built with Python via the Flask framework.

+
+ {% endblock %} \ No newline at end of file diff --git a/templates/layout.html b/templates/layout.html new file mode 100644 index 0000000..918074c --- /dev/null +++ b/templates/layout.html @@ -0,0 +1,25 @@ + + + + PARTOUT TITRE PARTOUT + + + +
+
+

SUPERB

+ +
+
+
+ {% block content %} + {% endblock %} +
+ + \ No newline at end of file