import flask
import string
import random
app = flask.Flask(__name__)
storage = {}
url = "http://deerenaros.pythonanywhere.com/"
def uid():
for i in xrange(0, 10):
yield random.choice(string.ascii_lowercase)
@app.route("/")
def hello_world():
urlid = "".join(uid())
storage[urlid] = {}
return """ Hi, now u can use {0} to access your table (in json).
You can also {0}/carina/9000 in order to set Carina's score over nine thousand """.format(url + urlid)
@app.route("/")
def get(uid):
return str(storage)
return flask.json.jsonify(storage[uid])
@app.route("///")
def set(uid, name, score):
if uid not in storage:
return "There is no such table"
storage[uid][name] = score
return flask.json.jsonify(storage[uid])