I'm creating a basic web app with Jester.
Having problems with Format().
When I access the register-form route I get an error : Invalid Format string
Code below. Any ideas?
import jester
import strutils
const REGISTER_FORM = """<html>
<head>
<title>Test Page</title>
</head>
<body>
<h3>Register</h3>
Enter your email address to sign up
<p>
<b>$l</b>
<p>
<form action="/register-form" method="POST">
<input type="text" name="email" />
<button type="submit">Send Email Address</button>
</form>
</body>
</html>
"""
routes:
get "/":
resp "TODO"
get "/register-form":
resp REGISTER_FORM.format(@"")
get "/register-form/@err":
resp REGISTER_FORM.format(@"err")
post "/register-form":
if request.params["email"]=="":
redirect "/register-form/$l".format("Need Email Address")
else:
redirect "/hello/$1".format(request.params["email"])
get "/hello/@email":
resp "hello $1!".format(@"email")
post "/":
resp "TODO"
I recognize this code. :) If you would like the original, I've been placing the website code after each section of the YouTube series at: https://github.com/JohnAD/bookclub
If you look at the releases, each release points to the commit for that part of the video.
That reminds me...I've written episode 3 but need to get it published.