Created
August 10, 2015 19:43
-
-
Save feihong/a2c53ed3e026f62c8c0a to your computer and use it in GitHub Desktop.
Very simple TinyWebDB-compliant server app for use with App Inventor
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
| import json | |
| from flask import Flask, request | |
| app = Flask(__name__) | |
| db = {} | |
| @app.route('/') | |
| def hello_world(): | |
| return repr(db) | |
| @app.route('/tinywebdb/getvalue', methods=['GET', 'POST']) | |
| def get_value(): | |
| tag = request.values.get('tag') | |
| value = db.get(tag, '') | |
| return json.dumps(['VALUE', tag, value]) | |
| @app.route('/tinywebdb/storeavalue', methods=['GET', 'POST']) | |
| def store_value(): | |
| values = request.values | |
| tag = values.get('tag') | |
| value = values.get('value') | |
| db[tag] = value | |
| print db | |
| return json.dumps(['STORED', tag, value]) | |
| if __name__ == '__main__': | |
| app.run(debug=True, host='0.0.0.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment