add app.py timer.py

This commit is contained in:
aozhiwei 2019-09-12 15:21:06 +08:00
parent 85bf301bea
commit 98f18fc666
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
#!/usr/bin/python
from .app import instance as i_app
from .timer import instance as i_timer
from .udplog import instance as i_udplog
app = i_app()
udplog = i_udplog()
timer = i_timer()

41
f7/app.py Normal file
View File

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
#!/usr/bin/python
import tornado.web
import tornado.ioloop
class _mainHandler(tornado.web.RequestHandler):
def get(self):
self.write(json.dumps({
'errcode': 0,
'errmsg': '',
'healthy': 1,
'max_rundelay': 10
}))
class _App:
_instance = None
@classmethod
def instance(cls):
if not cls._instance:
cls._instance = _App()
return cls._instance
def __init__(self):
self._app = tornado.web.Application([
(r"/webapp/index[\.]php", _mainHandler),
])
def start(self):
tornado.ioloop.IOLoop.current().start()
def listen(self, port):
self._app.listen(port)
def callAt(self, when, callback):
tornado.ioloop.IOLoop.current().call_at(when, callback)
def instance():
return _App.instance()

22
f7/timer.py Normal file
View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
#!/usr/bin/python
import f7
class _Timer:
_instance = None
@classmethod
def instance(cls):
if not cls._instance:
cls._instance = _Timer()
return cls._instance
def __init__(self):
pass
def callAt(self, when, callback):
f7.app.callAt(when, callback)
def instance():
return _Timer.instance()