def main(): # from tornado.ioloop import IOLoop # from tornado.platform.asyncio import AsyncIOMainLoop import asyncio from wdom.misc import install_asyncio install_asyncio() from wdom.server import start_server, get_app, stop_server # from wdom.server_aio import start_server, get_app, stop_server # from wdom.server_tornado import start_server, get_app, stop_server # from wdom.examples.markdown_simple import sample_page # from wdom.examples.rev_text import sample_page # from wdom.examples.data_binding import sample_page # from wdom.examples.todo import sample_page from wdom.examples.theming import sample_page # from wdom.themes import bootstrap3, mdl, skeleton, pure, semantic, kube, foundation, mui from wdom.themes import default page = sample_page(default) app = get_app(document=page) loop = asyncio.get_event_loop() server = start_server(app=app, loop=loop) try: loop.run_forever() except KeyboardInterrupt: stop_server(server) loop.close()
def tearDown(self) -> None: """Run tear down process. Reset log-level, stop web server, and flush stdout. """ options.config.logging = self._prev_logging server.stop_server() sys.stdout.flush() sys.stderr.flush() super().tearDown() # type: ignore
def tearDown(self) -> None: """Terminate server and close all ws client connections.""" if self._server_started: with self.assertLogs(root_logger, 'INFO'): server.stop_server(self.server) self._server_started = False while self._ws_connections: ws = self._ws_connections.pop() ws.close() super().tearDown()
def tearDown(self): """Terminate server and close all ws client connections.""" if self._server_started: with self.assertLogs("wdom", "INFO"): server.stop_server(self.server) self._server_started = False while self._ws_connections: ws = self._ws_connections.pop() ws.close() super().tearDown()
def main(): import asyncio from wdom.server import start_server, get_app, stop_server doc = sample_page() app = get_app(document=doc) loop = asyncio.get_event_loop() server = start_server(app=app, loop=loop) try: loop.run_forever() except KeyboardInterrupt: stop_server(server) loop.close()
import asyncio from wdom.document import get_document from wdom.server import start_server, stop_server from wdom.tag import Button if __name__ == '__main__': document = get_document() # Add <link>-tag sourcing bootstrap.min.css on <head> document.add_cssfile('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css') # Add <script>-tag sourcing jquery and bootstrap.min.js to <body> document.add_jsfile('https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js') document.add_jsfile('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js') # Add bootstrap button element document.body.appendChild(Button('click', class_='btn btn-primary')) start_server() try: asyncio.get_event_loop().run_forever() except KeyboardInterrupt: stop_server()
from wdom.server import get_app, start_server, stop_server from wdom.document import get_document from wdom.tag import Div, H1, Input class MyElement(Div): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.h1 = H1(parent=self) self.h1.textContent = 'Hello, WDOM' self.input = Input(parent=self) self.input.addEventListener('input', self.update) def update(self, event): self.h1.textContent = event.target.value if __name__ == '__main__': install_asyncio() # only when using tornado document = get_document() document.body.appendChild(MyElement()) app = get_app(document) loop = asyncio.get_event_loop() server = start_server(app, port=8888, loop=loop) try: loop.run_forever() except KeyboardInterrupt: stop_server(server)
def tearDown(self): stop_server(self.server) set_document(get_new_document()) sync(self.page.goto('about:blank')) time.sleep(0.1)
def tearDown(self): server.stop_server(self.server) super().tearDown() import time time.sleep(0.01)
class App(Div): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.text = H1(parent=self) self.text.textContent = 'Hello!' self.textbox = Input(parent=self) self.textbox.setAttribute('type', 'text') self.textbox.addEventListener('input', self.update) def update(self, event): self.text.textContent = self.textbox.getAttribute('value') def sample_app(**kwargs): return App() if __name__ == '__main__': import asyncio from wdom.document import get_document from wdom import server document = get_document() document.body.prepend(sample_app()) server.start_server() try: asyncio.get_event_loop().run_forever() except KeyboardInterrupt: pass server.stop_server()
def tearDown(self): options.config.logging = self._prev_logging server.stop_server() sys.stdout.flush() sys.stderr.flush() super().tearDown()
self.document.body.appendChild(self.ul) @on_event('*') @on_message('*') def every_frame(self, frame): li = Li() prefix = FRAME_PREFIX[frame.kind] text = frame_template.format(prefix=prefix, source=frame.source, name=frame.name) data = frame.data if data and not (len(data.keys()) == 1 and 'text' in data): text += data_template.format(data=pformat(data)) li.innerHTML = text self.ul.appendChild(li) if __name__ == '__main__': start_server() try: dom_agent = BrowserDOMAgent('dom') run_agents(dom_agent, shell=True, endpoint='redis://127.0.0.1:6379', auth=ZENTROPI_REDIS_PASSWORD) except KeyboardInterrupt: stop_server() finally: stop_server()