1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import os
- from flask import Flask
-
- def create_app(test_config=None):
- app = Flask(__name__, instance_relative_config=True)
- app.config.from_mapping(
- SECRET_KEY='dev',
- DATABASE=os.path.join(app.instance_path, 'upr_espera.sqlite'),
- )
-
- if test_config is None:
- app.config.from_pyfile('config.py', silent=True)
- else:
- app.config.from_mapping(test_config)
-
- try:
- os.makedirs(app.instance_path)
- except OSError:
- pass
-
- from . import db
- db.init_app(app)
-
- @app.route('/', methods=('GET', 'POST'))
- def index():
- if request.method == 'POST':
- cName = request.form['cName']
- cEmail = request.form['cEmail']
- error = None
-
- if not cName:
- error = 'Name is required.'
- elif not cEmail:
- error = 'Email is required'
- else:
- db = get_db()
- station_id = db.execute(
- 'SELECT s_id FROM station WHERE nombre_empleado=?',
- (place_holder)
- ).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)
- )
- db.execute(
- 'INSERT INTO turno (cName, cEmail, turn, timeArrival, station)'
- ' VALUES (?, ?, ?, ?)',
- (cName, cEmail, turn, 'testin', station_id)
- )
- db.commit()
-
- return app
|