Skip to content

Instantly share code, notes, and snippets.

@pedrohbtp
Last active November 14, 2018 13:28
Show Gist options
  • Save pedrohbtp/958224371afd40970a41b88ba0ad5336 to your computer and use it in GitHub Desktop.
Save pedrohbtp/958224371afd40970a41b88ba0ad5336 to your computer and use it in GitHub Desktop.
Basic Flask Example
from flask import Flask
import flask
import json
from flask import Response
app = Flask(__name__)
@app.route('/test',methods=['GET'])
def test():
'''
GET: Receives the request in /test route and returns a response containing {"response": "test"}
'''
resp = Response(response=json.dumps({"response": "test"}), status=200, mimetype='application/json')
return resp
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=8082)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment