Created
June 21, 2018 12:17
-
-
Save onetown/1b7683b478088458f24f17f6bd8ee8a7 to your computer and use it in GitHub Desktop.
app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
import os | |
from flask import Flask | |
from redis import Redis | |
app = Flask(__name__) | |
redis = Redis(host='localhost', port=6379) | |
@app.route('/') | |
def hello(): | |
count = redis.incr('hits') | |
result = "<h1>node:" + os.environ.get('HOSTNAME') + "</h1><p>" | |
result = result + "<br>该页面已被访问<span style='color:red;font-size:24px;'>" + str(count) + "</span>次" | |
return result | |
if __name__ == '__main__': | |
app.run(host="0.0.0.0",debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment