server {
       listen 443;
       ssl on;
       ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
       ssl_certificate_key  /etc/ssl/private/ssl-cert-snakeoil.key;
(…)
}

def extract_user(handler):
    auth_header = handler.request.headers.get('Authorization')
    auth_header = base64.decodestring(auth_header[6:])
    user = auth_header.split(':', 2)[0]
    return user

    def post(self):
        data = json.loads(self.request.body)
(…)
        user = extract_user(self)
        result["user"] = user
(…)

    def get(self, prob_id):
        result = self.storage[prob_id]
        user = extract_user(self)
        if result["user"] == user:
            self.write(json.dumps(result))
        else:
            self.set_status(401)
            self.finish("You have no permission to acces to this resource")

from pymemcache.client import Client
class Storage(object):
    def __init__(self):
        self.client = Client(('localhost', 11211))

    def __getitem__(self, key):
        return json.loads(self.client.get(key))

    def __setitem__(self, key, data):
        self.client.set(key, json.dumps(data))
storage = Storage()

import uuid
(…)
class ProblemsHandler(tornado.web.RequestHandler):
(…)
    def post(self):
        data = json.loads(self.request.body)
        prob_id = str(uuid.uuid1())
(…)

if __name__ == "__main__":
    if len(sys.argv) > 1:
        port = int(sys.argv[1])
    else:
        port = 8888
    application.listen(port)
    tornado.ioloop.IOLoop.instance().start()