Created
September 18, 2015 05:39
-
-
Save joeclark-phd/1c2e56af8b7a2a01e3a4 to your computer and use it in GitHub Desktop.
quick JSON api mockup with flask that works on heroku
This file contains 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
import os | |
from flask import Flask, jsonify | |
app = Flask(__name__) | |
# listing all items | |
@app.route("/api/items", methods=['GET']) | |
def list_items(): | |
fake_data = { "items": [ {"name":"Widget","id":42,"price":49.95}, | |
{"name":"Doodad","id":43,"price":19.95}, | |
{"name":"Gizmo","id":44,"price":99.95} ] | |
} | |
return( jsonify(fake_data) ) | |
if __name__ == "__main__": | |
port = int(os.environ.get("PORT", 5000)) | |
app.run(host='0.0.0.0', port=port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment