Skip to content

Instantly share code, notes, and snippets.

@feihong
Created August 10, 2015 19:43
Show Gist options
  • Save feihong/a2c53ed3e026f62c8c0a to your computer and use it in GitHub Desktop.
Save feihong/a2c53ed3e026f62c8c0a to your computer and use it in GitHub Desktop.
Very simple TinyWebDB-compliant server app for use with App Inventor
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