#!/usr/bin/env python3 # -*- coding: utf-8 -*- from wdom.event import Event from wdom.themes import H1 def rev_text(event: Event) -> None: elm = event.currentTarget elm.textContent = elm.textContent[::-1] def sample_app(**kwargs) -> H1: h1 = H1('Click!') h1.addEventListener('click', rev_text) return h1 if __name__ == '__main__': from wdom.document import set_app from wdom import server set_app(sample_app()) server.start()
def loop_in_thread(loop): logger.debug("Starting loop: `{}` in thread".format(loop)) asyncio.set_event_loop(loop) start() logger.debug("Started loop in thread")
from wdom.document import get_document from wdom.server import start 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()
def start_server(port: int) -> None: from wdom import server server.start(port=port)
def main(): set_app(sample_page()) server.start()
import time import subprocess import unittest from selenium.webdriver.common.utils import free_port from syncer import sync from wdom import server from wdom.document import get_document from wdom.util import suppress_logging from .base import HTTPTestCase curdir = path.dirname(__file__) root = path.dirname(path.dirname(curdir)) script = ''' from wdom import document, server doc = document.get_document() with open(doc.tempdir + '/a.html', 'w') as f: f.write(doc.tempdir) server.start() ''' def setUpModule(): suppress_logging() class TestServerBase(HTTPTestCase): cmd = []
def main(): from wdom import server sample_page() server.start()
from wdom.document import set_app from wdom.server import start from wdom.tag import Div, H1, Input class MyElement(Div): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.h1 = H1() self.h1.textContent = 'Hello, WDOM' self.input = Input() self.input.addEventListener('input', self.update) self.appendChild(self.input) self.appendChild(self.h1) def update(self, event): self.h1.textContent = event.target.value if __name__ == '__main__': set_app(MyElement()) server = start()