diff --git a/app/__init__.py b/app/__init__.py index 82b47ea..6cd8550 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,5 +1,7 @@ from flask import Flask +from config import Config app = Flask(__name__) +app.config.from_object(Config) from app import routes \ No newline at end of file diff --git a/app/config.py b/app/config.py new file mode 100644 index 0000000..ac23196 --- /dev/null +++ b/app/config.py @@ -0,0 +1,4 @@ +import os + +class Config(object): + SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(16) diff --git a/app/forms.py b/app/forms.py new file mode 100644 index 0000000..10c21df --- /dev/null +++ b/app/forms.py @@ -0,0 +1,9 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, PassworkField, BooleanField, SubmitField +from wtforms.validators import DataRequired + +class LoginForm(FlaskForm): + username = StringField('Username', validators=[DataRequired()]) + password = PasswordField('Password', validators=[DataRequired()]) + remember_me = BooleanField('Remember Me') + submit = SubmitField('Sign In') diff --git a/app/routes.py b/app/routes.py index 529888e..db55207 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,11 +1,27 @@ from flask import render_template from app import app +from app.forms import LoginForm from flask import send_file from flask import send_from_directory @app.route('/') @app.route('/index') def index(): + user = {'username': 'Miguel'} + posts = [ + { + 'author': {'username': 'John'}, + 'body': 'Beautiful day in Portland!' + }, + { + 'author': {'username': 'Susan'}, + 'body': 'The Avengers movie was so cool!' + } + ] + return render_template('index.html', title='Home', user=user, posts=posts) + +@app.route('/status') +def getstatus(): device = {'name': 'find how to get name later'} status = {'temperature': float(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1000} return render_template('status.html', device=device, status=status) diff --git a/app/templates/base.html b/app/templates/base.html new file mode 100644 index 0000000..7b392ba --- /dev/null +++ b/app/templates/base.html @@ -0,0 +1,14 @@ + +
+ {% if title %} +