bug fix and example added
This commit is contained in:
19
examples/set_sessions.py
Normal file
19
examples/set_sessions.py
Normal 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)
|
||||
Reference in New Issue
Block a user