Skip to content
Myr

views.py

This file

Path

examples/javascript/js_example/views.py

16 lines · 415 bytes · Python

Last changed by

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

History of this file

Take it

1from flask import jsonify, render_template, request23from js_example import app456@app.route("/", defaults={"js": "plain"})7@app.route("/<any(plain, jquery, fetch):js>")8def index(js):9    return render_template("{0}.html".format(js), js=js)101112@app.route("/add", methods=["POST"])13def add():14    a = request.form.get("a", 0, type=float)15    b = request.form.get("b", 0, type=float)16    return jsonify(result=a + b)