Browse Source

adding context stuff

master
zeroth 6 years ago
parent
commit
247dd7fb91
  1. 32
      contextualise.py
  2. 2
      startform.py
  3. 4
      static/css/main.css
  4. 10
      templates/about.html
  5. 10
      templates/description.html
  6. 7
      templates/home.html
  7. 25
      templates/layout.html

32
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)

2
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 flask import session as login_session
from forms import ReusableForm from forms import ReusableForm
from config import Config from config import Config
import json import json
app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates") 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(): if request.method == 'POST' and form.validate():
return 'Success' return 'Success'
return render_template('description.html', form=form) return render_template('description.html', form=form)
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug = True) app.run(debug = True)

4
static/css/main.css

@ -0,0 +1,4 @@
body{
background: lavender;
color:blue;
}

10
templates/about.html

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<body>
{% extends "layout.html" %}
{% block content %}
<div class="about">
<h1>About me</h1>
<p>This is a portfolio site about anything that can be put in a portfolio.</p>
</div>
{% endblock %}

10
templates/description.html

@ -1,6 +1,6 @@
<!doctype html> {% extends "layout.html" %}
<html> {% block content %}
<body> <div class="description">
<h2 style = "text-align: center;">Write something very interesting here.</h2> <h2 style = "text-align: center;">Write something very interesting here.</h2>
{% for message in form.name.errors %} {% for message in form.name.errors %}
<div>{{ message }}</div> <div>{{ message }}</div>
@ -16,5 +16,5 @@
<div>{{ form.submit }}</div> <div>{{ form.submit }}</div>
</fieldset> </fieldset>
</form> </form>
</body> </div>
</html> {% endblock %}

7
templates/home.html

@ -0,0 +1,7 @@
{% extends "layout.html" %}
{% block content %}
<div class="home">
<h1>THIS IS THE HOME PAGE</h1>
<p>This website was built with Python via the Flask framework.</p>
</div>
{% endblock %}

25
templates/layout.html

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>PARTOUT TITRE PARTOUT</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
</head>
<body>
<header>
<div class="container">
<h1 class="logo">SUPERB</h1>
<strong><nav>
<ul class="menu">
<li><a href="{{ url_for('home') }}">Home</a></li>
<li><a href="{{ url_for('about') }}">About</a></li>
<li><a href="{{ url_for('description') }}">Form</a></li>
</ul>
</nav></strong>
</div>
</header>
<div class="container">
{% block content %}
{% endblock %}
</div>
</body>
</html>
Loading…
Cancel
Save