ATX Learning (Four) -atxserver2

ATXSERVER2

A, main () file to start

1, the first by a return parse_args Namespace make some configuration, log in SimpleLoginHandler this page html inside that says,
2, then () to create the database by db.setup
3, by make_app done some html, static files and other configuration

def make_app(login_handler, **settings):
    settings['template_path'] = 'templates'
    settings['static_path'] = 'static'
    settings['cookie_secret'] = os.environ.get("SECRET", "SECRET:_")
    settings['login_url'] = '/login'
    settings['websocket_ping_interval'] = 10

    urlpatterns.append((r"/login", login_handler))
    return tornado.web.Application(urlpatterns, **settings)

 



4, start the service monitor monitor port4000
here you can see the login page


5. Enter the name of any login page
and then find the code under SimpleLoginHandler by
adding await self.set_current_user (email, name) account information into the database
6. The page will be redirected to the mobile devices to receive information sent websocket

 

class MainHandler(AuthRequestHandler):
    def get(self):
        self.redirect("/devices")
 

_data_handler, dumps the data processing jsondata.py file:

def _data_handler(obj):
    return obj.strftime(TIME_ISOFORMAT) if isinstance(
        obj, datetime.datetime) else obj


def dumps(data):
    assert isinstance(data, dict)
    return json.dumps(data, default=_data_handler)
 

Second, the remote control device
click to use
time reasons, the code being seen here today

Currently still learning, we hope everyone will help, feel good, they point to support what praise. In addition, there is something wrong or need to correct me. Thank you!

Guess you like

Origin www.cnblogs.com/dangkai/p/10938512.html