No Description

index.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from flask import (
  2. Blueprint, flash, g, redirect, render_template, request, url_for
  3. )
  4. from werkzeug.exceptions import abort
  5. from app.db import get_db
  6. bp = Blueprint('index', __name__)
  7. @bp.route('/', methods=('GET', 'POST'))
  8. def index():
  9. if request.method == 'POST':
  10. cName = request.form['cName']
  11. cEmail = request.form['cEmail']
  12. station_name = request.form['station']
  13. db = get_db()
  14. station_id = db.execute(
  15. 'SELECT s_id FROM station WHERE nombre_empleado=?',
  16. (station_name,)
  17. ).fetchone()
  18. db.execute(
  19. 'UPDATE station SET last_turn = last_turn + 1 WHERE s_id=?',
  20. (station_id,)
  21. )
  22. turn = db.execute(
  23. 'SELECT last_turn FROM station WHERE s_id=?',
  24. (station_id,)
  25. ).fetchone()
  26. db.execute(
  27. 'INSERT INTO turno (cName, cEmail, turn, timeArrival, station)'
  28. ' VALUES (?, ?, ?, ?)',
  29. (cName, cEmail, turn, 'testin', station_id)
  30. )
  31. db.commit()
  32. return redirect(url_for('index'))
  33. return render_template('index.html')