コード例 #1
0
ファイル: app.py プロジェクト: andre223/cse491-drinkz
def liquorTypesList():
    # this sets up jinja2 to load templates from the 'templates' directory

    loader = jinja2.FileSystemLoader("../drinkz/templates")
    env = jinja2.Environment(loader=loader)

    # pick up a filename to render
    filename = "pages.html"

    liqourTypesList = list()
    for (m, l) in db.get_liquor_types():
        liqourTypesList.append(str(m) + " " + str(l))

    # variables for the template rendering engine
    vars = dict(
        title="Liquor Types List",
        addtitle="<p>Add Liquor Type",
        form="""<form action='addType'>
Manufacturer<input type='text' name='mfg' size'20'><p>
Liquor<input type='text' name='liquor' size'20'><p>
Generic Type<input type='text' name='typ' size'20'><p>
<input type='submit'>
</form>""",
        names=liqourTypesList,
    )

    template = env.get_template(filename)

    x = template.render(vars).encode("ascii", "ignore")
    return x
コード例 #2
0
ファイル: app.py プロジェクト: Tempas/hw5-drinkz
def liqourTypesList():
    # this sets up jinja2 to load templates from the 'templates' directory
    
    loader = jinja2.FileSystemLoader('../drinkz/templates')
    env = jinja2.Environment(loader=loader)

    # pick up a filename to render
    filename = "listPages.html"

    #recipe nonsense
    liqourTypesList = list()
    for (m,l) in db.get_liquor_types():
        liqourTypesList.append(str(m)+ " " + str(l))
 
    
    # variables for the template rendering engine

    vars = dict(title = 'Liquor Types List', addtitle = "Add Liquor Type",
                form = """<form action='addType'>
Manufacturer<input type='text' name='mfg' size'20'>
Liquor<input type='text' name='liquor' size'20'>
Generic Type<input type='text' name='typ' size'20'><p>
<input type='submit'>
</form>""", names=liqourTypesList)


    
    try:
        template = env.get_template(filename)
    except Exception:# for nosetests
        loader = jinja2.FileSystemLoader('./drinkz/templates')
        env = jinja2.Environment(loader=loader)
        template = env.get_template(filename)

    x = template.render(vars).encode('ascii','ignore')
    return x
コード例 #3
0
ファイル: app.py プロジェクト: andre223/cse491-drinkz
    def rpc_get_liqour_types(self):
        liqourTypeList = list()

        for (m, l) in db.get_liquor_types():
            liqourTypeList.append((m, l))
        return liqourTypeList