Skip to content

Instantly share code, notes, and snippets.

@femmerling
Last active December 14, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save femmerling/5054458 to your computer and use it in GitHub Desktop.
Save femmerling/5054458 to your computer and use it in GitHub Desktop.
Editing contact/add routing
@app.route('/contact/')
def contact_add_controller():
#this is the controller to add new model entries
return render_template('contact_add.html', title = "Add New Entry")
@app.route('/contact/create/',methods=['POST','GET'])
def contact_create_data_controller():
# this is the contact data create handler
contact_name = request.values.get('contact_name')
contact_email = request.values.get('contact_email')
message = request.values.get('message')
new_contact = Contact(
contact_id = generate_key(),
contact_name = contact_name,
contact_email = contact_email,
message = message
)
db.session.add(new_contact)
db.session.commit()
return return 'Contact message sent <a href="/">back to home</a>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment