Skip to content

Commit

Permalink
session
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonEAX committed Nov 5, 2019
1 parent 78df918 commit a79b081
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# aiohttp test
9 changes: 9 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ async def get_auth(request):
# except Exception as e:
# responce_obj = {'status': 'success', 'message': str(e)}
# return web.Response(text=json.dumps(responce_obj), status=500)

session = await get_session(request)
print(str(session))
# last_visit = session['last_visit'] if 'last_visit' in session else None
session['last_visit'] = time.time()
# text = 'Last visited: {}'.format(last_visit)
# //return web.Response(text=text)

context = {'name': 'Andrew', 'surname': 'Svetlov'}
response = aiohttp_jinja2.render_template('auth.html',
request,
Expand Down Expand Up @@ -110,6 +118,7 @@ def make_app():
# secret_key must be 32 url-safe base64-encoded bytes
fernet_key = fernet.Fernet.generate_key()
secret_key = base64.urlsafe_b64decode(fernet_key)
# print(secret_key.decode('utf8'))
setup(app, EncryptedCookieStorage(secret_key))


Expand Down
4 changes: 2 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
<li class="nav-item">
<a class="nav-link" href="/table">Table</a>
</li>
<li class="nav-item">
{#<li class="nav-item">
{% if name %}
<a href="/login">Login</a>
{% else %}
<a href="/logout">Logout</a>
{% endif %}

</li>
</li>#}
</ul>
</div>
</nav>
Expand Down

0 comments on commit a79b081

Please sign in to comment.