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)
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)
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)
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")
def show_home(): form = CupcakeForm() return render_template('home.html', form=form)
def render_index(): form = CupcakeForm() return render_template('index.html', form=form)
def home_page(): form = CupcakeForm() return render_template('home.html', form=form)
def home_page(): """displays a home page""" form = CupcakeForm() return render_template("home.html", form=form)
def base_URL(): """Show homepage for cupcakes""" form = CupcakeForm() search_form = CupcakeSearchForm() return render_template("base.html", form=form, search_form=search_form)