Add first "Hello World" webinterface
This commit is contained in:
parent
61da307aa2
commit
9878acd9b6
3 changed files with 26 additions and 2 deletions
|
@ -70,7 +70,7 @@ if __name__ == '__main__':
|
|||
cfg = configreader.ConfigurationReader()
|
||||
cfg.read('fetap.ini')
|
||||
|
||||
phone = PhoneInterface(cfg.phoneconfig)
|
||||
phone = PhoneInterface(cfg.phoneconfig, webinterface_enabled=True, api_enabled=True)
|
||||
feap = FeApUserInterface(cfg.pinconfig)
|
||||
controller = statemachine.StateMachineController(phone, feap, cfg.dialconfig)
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@ class PhoneEvent(object):
|
|||
|
||||
|
||||
class PhoneInterface(object):
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, webinterface_enabled = False, api_enabled = False):
|
||||
self.webinterface_enabled = webinterface_enabled
|
||||
self.api_enabled = api_enabled
|
||||
self.__event_cbs = []
|
||||
|
||||
self.__config = config
|
||||
|
@ -81,6 +83,10 @@ class PhoneInterface(object):
|
|||
#self.__core.video_capture_enabled = False
|
||||
#self.__core.video_display_enabled = False
|
||||
|
||||
if self.webinterface_enabled:
|
||||
from webinterface import FeTapWeb
|
||||
self.webinterface = FeTapWeb(api_enabled=api_enabled)
|
||||
|
||||
|
||||
def run_callbacks(self, evt):
|
||||
print(PhoneEvent.string(evt))
|
||||
|
@ -104,10 +110,16 @@ class PhoneInterface(object):
|
|||
self.__core.process_event()
|
||||
time.sleep(0.2) # Value for good measure
|
||||
|
||||
def __webthread(self):
|
||||
self.webinterface.start("0.0.0.0", 8080)
|
||||
|
||||
def start(self):
|
||||
self.__running = True
|
||||
t = threading.Thread(target=self.__pollthread)
|
||||
t.start()
|
||||
if self.webinterface_enabled:
|
||||
w = threading.Thread(target=self.__webthread)
|
||||
w.start()
|
||||
|
||||
def stop(self):
|
||||
self.stop_playing()
|
||||
|
|
12
webinterface.py
Normal file
12
webinterface.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import bottle
|
||||
|
||||
class FeTapWeb():
|
||||
def __init__(self, api_enabled=False):
|
||||
pass
|
||||
|
||||
@bottle.route("/")
|
||||
def root():
|
||||
return "<h1>Hello world!</h1>"
|
||||
|
||||
def start(self, host, port):
|
||||
bottle.run(host=host, port=port)
|
Loading…
Reference in a new issue