Files
fission-src/examples/python/guestbook/add.py
T
Soam VasaniandGitHub 91094cf659 Fix broken redirect (#467)
By default, flask turns redirects into absolute URLs. This is
undesired behaviour on Kubernetes, because the Pod's own IP address is
not really useful to any client that's not in the cluster (and even
within the cluster most clients will want to use the address of a
Service, not a Pod).
2018-01-30 12:00:30 -08:00

19 lines
482 B
Python

#
# Handles POST /guestbook -- adds item to guestbook
#
from flask import request, redirect
import redis
# Connect to redis.
redisConnection = redis.StrictRedis(host='redis.guestbook', port=6379, db=0)
def main():
# Read the item from POST params, add it to redis, and redirect
# back to the list
item = request.form['text']
redisConnection.rpush('guestbook', item)
r = redirect('/guestbook', code=303)
r.autocorrect_location_header = False
return r