Skip to content

Instantly share code, notes, and snippets.

@onetown
Created June 21, 2018 12:17
Show Gist options
  • Save onetown/1b7683b478088458f24f17f6bd8ee8a7 to your computer and use it in GitHub Desktop.
Save onetown/1b7683b478088458f24f17f6bd8ee8a7 to your computer and use it in GitHub Desktop.
app.py
#!/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