first commit
This commit is contained in:
BIN
__pycache__/bottle.cpython-38.pyc
Normal file
BIN
__pycache__/bottle.cpython-38.pyc
Normal file
Binary file not shown.
33
app.py
Executable file
33
app.py
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
from bottle import get, post, run, template
|
||||||
|
import smtplib
|
||||||
|
|
||||||
|
|
||||||
|
def send_confirm_email():
|
||||||
|
print('Sending confirmation email')
|
||||||
|
host = 'localhost'
|
||||||
|
port = 1025
|
||||||
|
server = smtplib.SMTP(host, port)
|
||||||
|
FROM = "welcome@superbuzz.com"
|
||||||
|
TO = "you@example.com"
|
||||||
|
MSG = """Subject: Welcome to SuperBuzz!
|
||||||
|
|
||||||
|
You're just one click away from SuperBuzz bliss! Click this confirmation link:
|
||||||
|
[confirmation link].
|
||||||
|
"""
|
||||||
|
server.sendmail(FROM, TO, MSG)
|
||||||
|
server.quit()
|
||||||
|
print('Confimration email sent.')
|
||||||
|
|
||||||
|
|
||||||
|
@get('/')
|
||||||
|
def home():
|
||||||
|
return template('home')
|
||||||
|
|
||||||
|
@post('/go')
|
||||||
|
def go():
|
||||||
|
send_confirm_email()
|
||||||
|
return template('go')
|
||||||
|
|
||||||
|
run(host='localhost', port=8080, debug=True)
|
||||||
11
views/go.tpl
Normal file
11
views/go.tpl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<html>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Well done!</h1>
|
||||||
|
|
||||||
|
<p>We've sent you a confirmation email.</p>
|
||||||
|
<p>Check you inbox and confirm your subscription!</p>
|
||||||
|
|
||||||
|
<div><a href="/">[Back to home page]</a></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
19
views/home.tpl
Normal file
19
views/home.tpl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<html>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Welcome to SuperBuzz!</h1>
|
||||||
|
|
||||||
|
<p>Use this form to sign-up and know all about the latest buzz!</p>
|
||||||
|
|
||||||
|
|
||||||
|
<form action="go" method="POST">
|
||||||
|
<label for="email_address">Email address:</label><br>
|
||||||
|
<input type="email" id="email_address" name="email_address"><br>
|
||||||
|
<label for="fullname">Full name:</label><br>
|
||||||
|
<input type="text" id="fullname" name="fullname">
|
||||||
|
<br /><br />
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user