mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-06 01:41:20 +00:00
Create handler for login
This commit is contained in:
parent
4a810b4229
commit
e0d13840f0
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
0
src/app/__init__.py
Normal file
0
src/app/__init__.py
Normal file
@ -7,13 +7,14 @@ from tornado.web import Application
|
|||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
from config import WEB_PORT
|
from config import WEB_PORT
|
||||||
from handlers import MainHandler, ZMQWebSocketHandler
|
from handlers import MainHandler, ZMQWebSocketHandler, LoginWebappHandler
|
||||||
import ui_modules
|
import ui_modules
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
routes = [
|
routes = [
|
||||||
(r'/', MainHandler),
|
(r'/', MainHandler),
|
||||||
(r'/ws', ZMQWebSocketHandler),
|
(r'/ws', ZMQWebSocketHandler),
|
||||||
|
(r'/login', LoginWebappHandler),
|
||||||
]
|
]
|
||||||
application = Application(
|
application = Application(
|
||||||
routes,
|
routes,
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
from .main_handler import MainHandler
|
from .main_handler import MainHandler
|
||||||
from .zmq_websocket_handler import ZMQWebSocketHandler
|
from .zmq_websocket_handler import ZMQWebSocketHandler
|
||||||
|
from .login_webapp_handler import LoginWebappHandler
|
||||||
|
27
src/app/handlers/login_webapp_handler.py
Normal file
27
src/app/handlers/login_webapp_handler.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
from tornado.web import RequestHandler, MissingArgumentError
|
||||||
|
|
||||||
|
# from buttons import fsm
|
||||||
|
from sql_injection_fsm import fsm
|
||||||
|
|
||||||
|
|
||||||
|
class LoginWebappHandler(RequestHandler):
|
||||||
|
anchor_id = 'anchor_login'
|
||||||
|
|
||||||
|
def get(self, *args, **kwargs):
|
||||||
|
self.render('login.html', anchor_id=self.anchor_id, form_data=(
|
||||||
|
('email', 'email_input', 'Email address', 'Enter email'),
|
||||||
|
('password', 'password_input', 'Password', 'Password'),
|
||||||
|
))
|
||||||
|
|
||||||
|
def post(self, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
message = {
|
||||||
|
'anchor': self.anchor_id,
|
||||||
|
'data': {k: self.get_body_argument(k) for k in ('email', 'password')}
|
||||||
|
}
|
||||||
|
fsm.trigger(self.anchor_id, message=json.dumps(message))
|
||||||
|
except MissingArgumentError:
|
||||||
|
self.write_error(status_code=400, message='Incomplete request')
|
||||||
|
# TODO: return real data if not in a tutorial
|
14
src/app/templates/login.html
Normal file
14
src/app/templates/login.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Login page</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="{{ static_url('vendor/css/bootstrap.min.css') }}">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
{% module Login(anchor_id, form_data) %}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user