Browse Source

Renomeia componentes.

master
Guilherme Capanema 7 years ago
parent
commit
0ede8f1554
11 changed files with 71 additions and 19 deletions
  1. +6
    -6
      app/__init__.py
  2. +1
    -1
      app/auth.py
  3. +0
    -0
      app/db.py
  4. +45
    -0
      app/lights.py
  5. +10
    -1
      app/schema.sql
  6. +6
    -8
      app/settings.py
  7. +0
    -0
      app/static/style.css
  8. +0
    -0
      app/templates/auth/login.html.j2
  9. +0
    -0
      app/templates/auth/register.html.j2
  10. +2
    -2
      app/templates/base.html.j2
  11. +1
    -1
      app/templates/lights/index.html.j2

interruptor/__init__.py → app/__init__.py View File


interruptor/auth.py → app/auth.py View File


interruptor/db.py → app/db.py View File


+ 45
- 0
app/lights.py View File

@ -0,0 +1,45 @@
from flask import (
Blueprint, flash, g, redirect, render_template, request, url_for
)
from werkzeug.exceptions import abort
from app.auth import login_required
from app.db import get_db
# import RPi.GPIO as GPIO
bp = Blueprint('lights', __name__)
@bp.route('/')
def index():
db = get_db()
status = db.execute(
'SELECT user_id, status, created'
' FROM status JOIN user ON status.user_id = user.id'
' ORDER BY created DESC LIMIT 1'
).fetchone()
return render_template('lights/index.html.j2', status=status)
@bp.route('/toggle')
@login_required
def toggle():
db = get_db()
status = db.execute(
'SELECT status'
' FROM status JOIN user ON status.user_id = user.id'
' ORDER BY created DESC LIMIT 1'
).fetchone()
# if status['status']:
# GPIO.output(17, GPIO.LOW)
# else:
# GPIO.output(17, GPIO.HIGH)
db.execute(
'INSERT INTO status (user_id, status)'
' VALUES (?, ?)',
(g.user['id'], not status['status'])
)
db.commit()
return redirect(url_for('lights.index'))

interruptor/schema.sql → app/schema.sql View File


interruptor/interruptor.py → app/settings.py View File


interruptor/static/style.css → app/static/style.css View File


interruptor/templates/auth/login.html.j2 → app/templates/auth/login.html.j2 View File


interruptor/templates/auth/register.html.j2 → app/templates/auth/register.html.j2 View File


interruptor/templates/base.html.j2 → app/templates/base.html.j2 View File


interruptor/templates/interruptor/index.html.j2 → app/templates/lights/index.html.j2 View File


Loading…
Cancel
Save