Skip to content

Instantly share code, notes, and snippets.

@bigkevmcd
Created December 17, 2015 11:12
Show Gist options
  • Save bigkevmcd/7d2d24adf327ff2aba86 to your computer and use it in GitHub Desktop.
Save bigkevmcd/7d2d24adf327ff2aba86 to your computer and use it in GitHub Desktop.
from flask import Flask
from logging.handlers import SysLogHandler
# $ python hello.py
# * Restarting with stat
# * Debugger is active!
# --------------------------------------------------------------------------------
# INFO in hello [hello.py:9]:
# Getting / in the Hello flask app
# --------------------------------------------------------------------------------
# 127.0.0.1 - - [17/Dec/2015 11:10:41] "GET / HTTP/1.1" 200 -
# and logged to syslog...
# Dec 17 11:10:38 Getting / in the Hello flask app
app = Flask(__name__)
app.logger.addHandler(SysLogHandler(('192.168.0.254', 514)))
@app.route('/')
def index():
app.logger.info("Getting / in the Hello flask app")
return '<h1>Hello World!</h1>'
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment