Example #1
0
def tempconvert():
    "post input for temperature"
    temptype = request.form['temptype']
    temp = float(request.form['temp'])

    if temptype == 'C':
        txt = render([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('celcius to farenheit')
                ),
                html.body(
                    str(C2F(temp))
                    )
            )
        ])
    elif temptype == 'F':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('farenheit to celcius')
                    ),
                html.body(
                    str(F2C(temp))
                    )
                )
            ])
    else:
        txt = 'Not valid input'
    return txt
Example #2
0
def weightconvert():
    "post input for weight"
    masstype = request.form['masstype']
    weight = float(request.form['weight'])

    if masstype == 'kg':
        txt = render([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('kilograms -> lbs')
                ),
                html.body(
                    str(k2p(weight))
                    )
            )
        ])
    elif masstype == 'lb':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('lbs -> kilograms')
                    ),
                html.body(
                    str(p2k(weight))
                    )
                )
            ])
    else:
        txt = 'not valid input'
    
    return txt
Example #3
0
def liquidconvert():
    "post input for liquid"
    liquidtype = request.form['liquidtype']
    liquid = float(request.form['liquid'])

    if liquidtype == 'L':
        txt = render([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('liters -> gallons')
                ),
                html.body(
                    str(l2g(liquid))
                    )
            )
        ])
    elif liquidtype == 'G':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('gallons -> liters')
                    ),
                html.body(
                    str(g2l(liquid))
                    )
                )
            ])
    elif liquidtype == 'l':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('liters -> ounces')
                    ),
                html.body(
                    str(l2o(liquid))
                    )
                )
            ]) 

    elif liquidtype == 'o':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('ounces -> liters')
                    ),
                html.body(
                    str(o2l(liquid))
                    )
                )
            ])   

    else:
        txt = 'not valid input'
    
    return txt
Example #4
0
def distanceconvert():
    "post input for distance"
    distancetype = request.form['distancetype']
    distanceamount = float(request.form['distanceamount'])

    if distancetype == 'm':
        txt = render([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('meters -> feet')
                    ),
                html.body(
                    str(M2F(distanceamount))
                    )
                )
            ])
    elif distancetype == 'ft':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('feet -> meters')
                    ),
                html.body(
                    str(F2M(distanceamount))
                    )
                )
            ])
    elif distancetype == 'KM':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('kilometers -> miles')
                    ),
                html.body(
                    str(K2M(distanceamount))
                    )
                )
            ])
    elif distancetype == 'Miles':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('miles -> kilometers')
                    ),
                html.body(
                    str(M2K(distanceamount))
                    )
                )
            ])
    else:
        txt = 'Not valid input'
    return txt
 def site_root():
     return [
         html.doctype('html'),
         html.html(
             html.head(),
             html.body(
                 g.blocks['body']
             )
         )
     ]
Example #6
0
 def site_root():
     return [
         html.doctype('html'),
         html.html(
             html.head(
                 html.has_attr('description')(
                     html.meta(content=Attr('description'))),
                 html.has_attr('author')(
                     html.meta(content=Attr('author')))), html.body())
     ]
Example #7
0
def test_nested_indentating():
    elements = [
        html.doctype('html'),
        html.html(lang='en',
                  class_='no-js')(html.head(html.title('Hello')),
                                  html.body(html.comment(' Body starts here '),
                                            html.p('Hello World!')))
    ]

    assert render(elements) == """<!doctype html>
def test_nested_indentating():
    elements = [
        html.doctype('html'),
        html.html(lang='en', class_='no-js')(
            html.head(
                html.title('Hello')
            ),
            html.body(
                html.comment(' Body starts here '),
                html.p('Hello World!')
            )
        )
    ]

    assert render(elements) == """<!doctype html>
 def site_root():
     return [
         html.doctype('html'),
         html.html(
             html.head(
                 html.has_attr('description')(
                     html.meta(content=Attr('description'))
                 ),
                 html.has_attr('author')(
                     html.meta(content=Attr('author'))
                 )
             ),
             html.body()
         )
     ]
def html5_boilerplate():
    return [
        html.doctype('html'),
        html.newline(),
        # paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
        html.comment(
            '[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]'),
        html.comment(
            '[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]'),
        html.comment(
            '[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]'),
        html.comment('[if (gte IE 9)|!(IE)]><!'),
        html.html(lang='en', class_='no-js')(html.comment('<![endif]'), head(),
                                             body())
    ]
def html5_boilerplate():
    return [
        html.doctype('html'),
        
        html.newline(),
        # paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
        html.comment('[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]'),
        html.comment('[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]'),
        html.comment('[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]'),
        html.comment('[if (gte IE 9)|!(IE)]><!'),
        html.html(lang='en', class_='no-js')(
            html.comment('<![endif]'),
            
            head(),
            body()
        )
    ]
def addserverpost():
    "post input for server total"
    servers = request.form['servers']
    txt = render([
        html.doctype('html'),
        html.html(lang='en')(
            html.head(
                html.title('Scalelab Server Calculator 5000')
            ),
            html.body(
                "%s Dell R620 node(s) with cabling, 2 x 10gbe ports (20GbE in/out) will cost $%s USD" \
                        % (servers,addserver(servers))
                )
            )
        ])

    return txt
def test_doctype():
    assert rn(html.doctype('html')) == '<!doctype html>'
    assert render(html.doctype('html')) == '<!doctype html>\n'
Example #14
0
 def site_root():
     return [
         html.doctype('html'),
         html.html(html.head(), html.body(g.blocks['body']))
     ]
Example #15
0
def test_doctype():
    assert rn(html.doctype('html')) == '<!doctype html>'
    assert render(html.doctype('html')) == '<!doctype html>\n'
Example #16
0
def currencyconvert():
    "post input for currency"
    currencytype = request.form['currencytype']
    currencyamount = float(request.form['currencyamount'])

    if currencytype == 'USD':
        txt = render([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('USD -> CZK')
                    ),
                html.body(
                    str(usdtoczk(currencyamount))
                    )
                )
            ])

    elif currencytype == 'CZK':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('CZK -> USD')
                    ),
                html.body(
                    str(czktousd(currencyamount))
                    )
                )
            ])

    elif currencytype == 'HRK':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('HRK -> USD')
                    ),
                html.body(
                    str(hrktousd(currencyamount))
                    )
                )
            ])

    elif currencytype == 'USD-H':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('USD -> HRK')
                    ),
                html.body(
                    str(usdtohrk(currencyamount))
                    )
                )
            ])

    elif currencytype == 'USD-E':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('USD -> EU')
                    ),
                html.body(
                    str(usdtoeu(currencyamount))
                    )
                )
            ])

    elif currencytype == 'E-USD':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('EU -> USD')
                    ),
                html.body(
                    str(eutousd(currencyamount))
                    )
                )
            ])

    elif currencytype == 'CZK-E':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('CZK -> EU')
                    ),
                html.body(
                    str(czktoeu(currencyamount))
                    )
                )
            ])

    elif currencytype == 'E-CZK':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('EU -> CZK')
                    ),
                html.body(
                    str(eutoczk(currencyamount))
                    )
                )
            ])

    elif currencytype == 'B-USD':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('BAHT -> USD')
                    ),
                html.body(
                    str(bhtousd(currencyamount))
                    )
                )
            ])

    elif currencytype == 'USD-B':
        txt = render ([
            html.doctype('html'),
            html.html(lang='en')(
                html.head(
                    html.title('BAHT -> USD')
                    ),
                html.body(
                    str(usdtobh(currencyamount))
                    )
                )
            ])

    else:
        txt = 'not valid input'

    return txt