From 4e1461a4921ba3df29d691a93baaf5771c8b09c3 Mon Sep 17 00:00:00 2001 From: Scoder12 <34356756+Scoder12@users.noreply.github.com> Date: Wed, 29 Jul 2020 11:08:35 -0700 Subject: [PATCH] Add needs_signin example --- examples/maqpy/needs_params.py | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 examples/maqpy/needs_params.py diff --git a/examples/maqpy/needs_params.py b/examples/maqpy/needs_params.py new file mode 100644 index 0000000..13e6f8b --- /dev/null +++ b/examples/maqpy/needs_params.py @@ -0,0 +1,37 @@ +from replit import maqpy + +app = maqpy.App(__name__) + + +@app.route("/") +def index(): + return """ + +Form testing + +

Form testing

+
+ +
+
+ + +
+ + +""" + + +# custom onerror function +def onerror(missing): + return f"Missing parameter {missing}" + + +@app.route("/form") +@maqpy.needs_params("param", onerror=onerror) +def form(param): + return f"The value of param is: {param}" + + +if __name__ == "__main__": + app.run()