bug fix and example added

This commit is contained in:
AZLisme
2017-08-11 14:00:59 +08:00
parent 4260b115e2
commit 2d9b7c090a
2 changed files with 21 additions and 2 deletions

19
examples/set_sessions.py Normal file
View File

@@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-
from sanic import Sanic
from sanic.response import json
app = Sanic()
@app.route("/")
async def test(request):
if request.session.get('key') is None:
request.session['key'] = 'value'
return json(dict(ok=True))
else:
return json(dict(key=request.session['key']))
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)