def render_index(stdout: list = None): doc = Doc('html') with head(): meta(charset='utf-8') [meta(**{k: v}) for k, v in META.items()] title('Libiocage-GUI') with style(): css.embed() with form(id='exec_form', title='Type a command to run in a jail.', ic__post__to='/exec', ic__target='#stdout', ic__indicator='#loading', ): label('Execute in one-shot jail:', _for='#command', id='exec_label') _input(id='exec_input', name='command', autofocus=True, ic__indicator='#loading', ) _input(id='exec_submit', type='submit', value='exec') img(src=url_for('static', filename='images/loader.gif'), alt='loading...', id='loading') with body(): with div(id='stdout'): if stdout: render_stdout(doc, stdout) script(src=url_for('static', filename='js/jquery-3.3.1.min.js'), type='text/javascript') script(src=url_for('static', filename='js/intercooler-1.2.1.min.js'), type='text/javascript') return str(doc)
def test_css_embed(): from makeweb import CSS, Doc, style css = CSS() css('body', background_color='black', color='green') doc = Doc() with style(): css.embed() assert str( doc) == '<style>body{background-color:black;color:green}</style>'
def index(): doc = Doc('html') # <-- html generation starts here... with head(): title('Hello') with style(): css.embed() with body(): h1('...', id='hello_box') button('Hello', onclick="say_hello()") # <-- hook up say_hello(). with script(): js.embed() return Response(str(doc)) # <-- ...and ends here.
async def index(): doc = Doc('html') with head(): meta(name='charset', content='utf-8') [meta(name=k, content=v) for k, v in META.items()] title('Anon?Chat') with style(): css.embed() with body(): with div(cls='page'): with div(cls='incoming_wrapper'): with ul(id='chat_log'): [li(' ') for x in range(50)] div('', id='bottom') _input(id='txt_message', onkeyup="send_message(event)", autofocus=True) button('⏎', onclick="send_message(event)", id='btn_send') with script(): js.embed() return Response(str(doc))
def index(): doc = Doc('html') with head(): title('Year 2038 problem') with style(): css.embed() with body(onload='start_timer()'): # Exercise: calculate these numbers in advance, in Python, # and fill them in, letting the page be useful # even if a user has disabled JS # (with adtech giving us many good reasons to do so!). # As a rule, even in 2018, do not assume JS is available by default. div(render_initial_timer(days='0000', hours='00', minutes='00', seconds='00'), cls='timer j-timer') div(a('to January 19, 2038 03:14:07', href='https://en.wikipedia.org/wiki/Year_2038_problem'), cls='legend-wrap') script(src='/static/timezz.js') with script(): # You can comment out this block js.embed() # to test render_initial_timer() return Response(str(doc))