init
This commit is contained in:
20
src/app.py
Normal file
20
src/app.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from flask import Flask
|
||||
import os
|
||||
import redis
|
||||
app = Flask(__name__)
|
||||
redis_host = 'test-redis'
|
||||
print("Redis host %s", redis_host)
|
||||
r = redis.Redis(host=redis_host, port=6379, db=0)
|
||||
|
||||
@app.route('/')
|
||||
def hello():
|
||||
return "Hello There, World!"
|
||||
|
||||
@app.route('/<name>')
|
||||
def hello_stranger(name=None):
|
||||
times = r.incr(name)
|
||||
return "Hello, %s! You have visited %s times.\n\n%s" % (name, times, os.environ['HOSTNAME'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
Reference in New Issue
Block a user