예제 #1
0
파일: flaskApp.py 프로젝트: grug7/brewapp
def person_form():
    if request.method == "GET":
        return render_template('add_person.html', title="Create Person Form", people=db.get_all_people_as_people(),
                               drinks=db.get_all_drinks_as_drinks())
    elif request.method == "POST":
        person_first_name = request.form.get("person-first-name")
        person_last_name = request.form.get("person-last-name")
        drink_name = request.form.get("drink-name")
        new_person = Person(person_first_name, person_last_name, Drink(drink_name))
        db.save_Person(new_person, db.get_all_drinks_as_drinks())
        return render_template("return_posted.html", title="Posted person", object=new_person)
예제 #2
0
파일: flaskApp.py 프로젝트: grug7/brewapp
def create_round():
    if request.method == "GET":
        return render_template('add_round.html', title="Create Form", people=db.get_all_people_as_people(),
                               drinks=db.get_all_drinks_as_drinks(),rounds=db.get_all_rounds_as_rounds())
    elif request.method == "POST":
        maker = request.form.get("maker")
        new_round = Round(maker)
        people = db.get_all_people_as_people()
        for index,person in enumerate(people):
            if request.form.get(f"checkbox{index}"):
                new_round.add_order(person)
        db.save_round(new_round,people,db.get_all_drinks_as_drinks(),db.get_all_rounds_as_rounds())
        return render_template("return_posted.html", title="Posted",object=new_round)
예제 #3
0
파일: flaskApp.py 프로젝트: grug7/brewapp
def post_people():
    try:
        new_person = get_person_from_JSON(request.get_json())
        db.save_Person(new_person, db.get_all_drinks_as_drinks())
        return jsonify(new_person)
    except Exception as e:
        print(f"POST Person error: {e}")
        abort(400)
예제 #4
0
파일: flaskApp.py 프로젝트: grug7/brewapp
def drink_form():
    if request.method == "GET":
        return render_template('add_drink.html', title="Create Drink Form", people=db.get_all_people_as_people(),
                               drinks=db.get_all_drinks_as_drinks())
    elif request.method == "POST":
        drink_name = request.form.get("drink-name")
        new_drink = Drink(drink_name)
        db.save_Drink(new_drink)
        return render_template("return_posted.html", title="Posted drink", object=new_drink)
예제 #5
0
파일: flaskApp.py 프로젝트: grug7/brewapp
def post_round():
    content = request.get_json()
    maker_json = content["maker"]
    maker = get_person_from_JSON(maker_json)
    new_round = Round(maker)
    for order in get_orders_from_JSON(content["orders"]):
        new_round.add_order(order[0], order[1])
    db.save_round(new_round, db.get_all_people_as_people(), db.get_all_drinks_as_drinks(),
                  db.get_all_rounds_as_rounds())
    return jsonify(new_round)
예제 #6
0
from http.server import HTTPServer, BaseHTTPRequestHandler
import helpers.dbHandler as db

drink_list = db.get_all_drinks_as_drinks()
people_list = db.get_all_people_as_people()
rounds_list = db.get_all_rounds_as_rounds()

head = """
<!DOCTYPE html>

<head>
    <title>brewapp</title>
    <style>
        body {
            background-image: url("https://media.giphy.com/media/vDQlLWAEsfs5i/source.gif");
            background-repeat: no-repeat;
            background-size: cover;
        }

        .center {
            display: block;
            margin-left: auto;
            margin-right: auto;
            width: 50%;
        }

        .box {
            background-color: white;
            color: black;
            font-weight: bold;
            margin: 120px auto;
예제 #7
0
파일: flaskApp.py 프로젝트: grug7/brewapp
def get_drinks():
    return jsonify(db.get_all_drinks_as_drinks())