Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 <a href={0}>{0}</a> to access your table (in json).<br/>
- You can also {0}/carina/9000 in order to set Carina's score over nine thousand """.format(url + urlid)
- @app.route("/<uid>")
- def get(uid):
- return str(storage)
- return flask.json.jsonify(storage[uid])
- @app.route("/<uid>/<name>/<score>")
- 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])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement