Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Created October 8, 2016 05:24
Show Gist options
  • Save gnilchee/f2e7f473e983e1125b0dd4ca62b35ddb to your computer and use it in GitHub Desktop.
Save gnilchee/f2e7f473e983e1125b0dd4ca62b35ddb to your computer and use it in GitHub Desktop.
simple flask app
#!/usr/bin/env python3
from flask import Flask,request,jsonify
app = Flask(__name__)
@app.route('/')
def default_rt():
return 'Welcome to the Atlas API'
@app.route('/ip', methods=["GET"])
def get_client_ip():
return jsonify({'ip': request.remote_addr}), 200
@app.route('/<path:path>')
def wildcard(path):
return jsonify({'error': '/%s is not a valid endpoint' % path }), 400
if __name__ == '__main__':
app.run(host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment