Created
October 8, 2016 05:24
-
-
Save gnilchee/f2e7f473e983e1125b0dd4ca62b35ddb to your computer and use it in GitHub Desktop.
simple flask app
This file contains hidden or 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 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