Skip to content

Instantly share code, notes, and snippets.

View leportella's full-sized avatar

Leticia Portella leportella

View GitHub Profile
function soma(x, y)
x + y
end
# retorna 5
soma(2, 3)
function pizza_favorita()
println("Minha 🍕 favorita é de 🎲🎲")
end
pizza_favorita()
println("Minha 🍕 favorita é de 🎲🎲")
from jupyterhub.auth import Authenticator
class NewAuth(Authenticator):
# ...
def validate_username(self, username):
if ' ' in username:
return False
return super().validate_username(username)
{% extends "page.html" %}
{% block main %}
<div class="container">
<h1> Your HTML goes here! </h1>
</div>
{% endblock %}
from jupyterhub.handlers import BaseHandler
class SignUpHandler(BaseHandler):
"""Render the sign up page."""
async def get(self):
html = self.render_template('signup.html')
self.finish(html)
from jupyterhub.auth import Authenticator
class NewAuth(Authenticator):
# ...
def get_handlers(self, app):
new_handlers = [
(r'/signup', SignUpHandler)
]
return super().get_handlers(app) + new_handlers
from jupyterhub.auth import Authenticator
from tornado import gen
class NewAuth(Authenticator):
# ...
@gen.coroutine
def authenticate(self, handler, data):
if self.can_login:
return data['username']
from jupyterhub.auth import Authenticator
from traitlets import Bool
class NewAuth(Authenticator):
can_login = Bool(
config=True,
default=False,
help="Allow users to login or not"
)
@leportella
leportella / basic-authenticator.py
Last active February 22, 2019 16:28
minimal jupyterhub authenticator
from jupyterhub.auth import Authenticator
from tornado import gen
class NewAuth(Authenticator):
@gen.coroutine
def authenticate(self, handler, data):
return data['username']