-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (23 loc) · 698 Bytes
/
Copy pathapp.py
File metadata and controls
29 lines (23 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
PART 1: APP
A simple Flask web application that shows the latest wats from the database
and accepts POST requests to queue new wats in DynamoDB.
Served through API Gateway and uses the `serverless-wsgi` plugin to translate
requests to WSGI, which is what Flask understands.
"""
import flask
import helpers
app = flask.Flask(__name__)
@app.route("/", methods=['GET'])
def index():
"""
Shows the latest wats!
"""
return flask.render_template('home.html', items=helpers.get_wats())
@app.route("/", methods=['POST'])
def create():
"""
Creates a brand new wat.
"""
helpers.create_wat(flask.request.form['url'])
return flask.redirect(flask.url_for('index'))