Esempio n. 1
0
def new_cupcake_form():
    """
    returns home page containing a form to add to the
    """
    form = CupcakeForm()
    form2 = EditCupcakeForm()
    return render_template('home.html', form=form, form2=form2)
Esempio n. 2
0
def home():
    cupcakes = Cupcake.query.all()

    form = CupcakeForm()
    search_form = SearchForm()

    if form.validate_on_submit():
        print("hi")
        return render_template('index.html',
                               cupcakes=cupcakes,
                               form=form,
                               search_form=search_form)
    else:
        print("Validation failed")

    return render_template('index.html',
                           cupcakes=cupcakes,
                           form=form,
                           search_form=search_form)
Esempio n. 3
0
File: app.py Progetto: demohack/yute
def show_cupcake_list():
    # GET /
    # This should return an HTML page (via render_template). This page should be entirely static
    # (the route should just render the template, without providing any information on cupcakes in the database).
    # It should show simply have an empty list where cupcakes should appear and a form where new cupcakes can be added.
    # Write Javascript (using axios and jQuery) that:
    #   queries the API to get the cupcakes and adds to the page
    #   handles form submission to both let the API know about the new cupcake and updates the list on the page to show it

    form = CupcakeForm()

    return render_template("index.html", form=form)
Esempio n. 4
0
def create_cupcake():
    """
    Add cupcake, and return data about new cupcake.

    Returns JSON like:
        {cupcake: [{id, flavor, rating, size, image}]}
    """

    form = CupcakeForm()

    if form.validate_on_submit():
        data = {k: v for k, v in form.data.items() if k != "csrf_token"}
        new_cupcake = Cupcake(**data)
        db.session.add(new_cupcake)
        db.session.commit()

        response_json = jsonify(cupcake=new_cupcake.serialize())
        return (response_json, 201)
    else:
        print('error occured')
        import pdb
        pdb.set_trace()
        return jsonify(message="form error")
Esempio n. 5
0
def show_home():
    form = CupcakeForm()
    return render_template('home.html', form=form)
Esempio n. 6
0
def render_index():
    form = CupcakeForm()
    return render_template('index.html', form=form)
Esempio n. 7
0
def home_page():
    form = CupcakeForm()
    return render_template('home.html', form=form)
Esempio n. 8
0
def home_page():
    """displays a home page"""
    form = CupcakeForm()
    return render_template("home.html", form=form)
Esempio n. 9
0
def base_URL():
    """Show homepage for cupcakes"""
    form = CupcakeForm()
    search_form = CupcakeSearchForm()
    return render_template("base.html", form=form, search_form=search_form)