from flask import Flask, render_template, request
from flask_bootstrap import Bootstrap
import db
import config
import pprint

app = Flask(__name__)
app.config.from_object(config.BaseConfig)
Bootstrap(app)
my_db = db.Database(app.config['DB_PATH'])

brew_name = "Fruit Beer"
brew_month = "October"


@app.route('/')
def hello_world():
    return render_template('index.html', brew_name=brew_name, brew_month=brew_month)


@app.route('/generate', methods=["POST"])
def generate():
    try:
        error = None
        identifier = my_db.get_identifier(request.form['name'])
        pass
    except StopIteration:
        identifier = ''
        error = 'Maximum entry limit reached - please contact Sean or Joe'
        pass
    return render_template('generate.html', brew_name=brew_name, brew_month=brew_month, identifier=identifier, error=error)


if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')



