1234567891011121314151617181920212223242526272829303132333435363738 |
- from flask import (
- Blueprint, flash, g, redirect, render_template, request, url_for
- )
- from werkzeug.exceptions import abort
-
- from app.db import get_db
-
- bp = Blueprint('index', __name__)
-
- @bp.route('/', methods=('GET', 'POST'))
- def index():
- if request.method == 'POST':
- cName = request.form['cName']
- cEmail = request.form['cEmail']
- station_name = request.form['station']
-
- db = get_db()
- station_id = db.execute(
- 'SELECT s_id FROM station WHERE nombre_empleado=?',
- (station_name,)
- ).fetchone()
- db.execute(
- 'UPDATE station SET last_turn = last_turn + 1 WHERE s_id=?',
- (station_id,)
- )
- turn = db.execute(
- 'SELECT last_turn FROM station WHERE s_id=?',
- (station_id,)
- ).fetchone()
- db.execute(
- 'INSERT INTO turno (cName, cEmail, turn, timeArrival, station)'
- ' VALUES (?, ?, ?, ?)',
- (cName, cEmail, turn, 'testin', station_id)
- )
- db.commit()
- return redirect(url_for('index'))
-
- return render_template('index.html')
|