示例#1
0
文件: app.py 项目: cymoo/minim
def render(template_name, **kwargs):
    from template import MiniTemplate
    app = app_stack.head
    if app.template_path is None:
        app.template_path = os.getcwd()
    full_path = os.path.join(app.template_path, app.template_folder, template_name)
    tpl = MiniTemplate(full_path)
    return tpl.render(**kwargs)
示例#2
0
def render(template_name, **kwargs):
    from template import MiniTemplate
    app = app_stack.head
    if app.template_path is None:
        app.template_path = os.getcwd()
    full_path = os.path.join(app.template_path, app.template_folder,
                             template_name)
    tpl = MiniTemplate(full_path)
    return tpl.render(**kwargs)
示例#3
0
from web import Minim, render, request, response
from template import MiniTemplate
from models import Person
from io import BytesIO

app = Minim()
greetings = 'The world is my idea~'
MiniTemplate.inject_context('greetings', greetings)


@app.get('/favicon.ico')
def favicon():
    return ''


@app.get('/')
def index():
    request.foo = 'bar'
    persons = Person.select()
    # print(request.foo)
    welcome = 'Keep calm and carry on!'
    motto = ['醒醒我们回家了', '世界是我的表象', '向死而生', '凡人所有的我都有']
    # print('host', request.host)
    # print('host-port', request.host_port)
    # print('path', request.path)
    # print('fullpath', request.full_path)
    # print('script-root', request.script_root)
    # print('url', request.url)
    # print('base-url', request.base_url)
    # print('url-root', request.url_root)
    # print('host-url', request.host_url)
示例#4
0
文件: views.py 项目: cymoo/minim
from web import Minim, render, request, response
from template import MiniTemplate
from models import Person
from io import BytesIO

app = Minim()
greetings = 'The world is my idea~'
MiniTemplate.inject_context('greetings', greetings)


@app.get('/favicon.ico')
def favicon():
    return ''


@app.get('/')
def index():
    request.foo = 'bar'
    persons = Person.select()
    # print(request.foo)
    welcome = 'Keep calm and carry on!'
    motto = ['醒醒我们回家了', '世界是我的表象', '向死而生', '凡人所有的我都有']
    # print('host', request.host)
    # print('host-port', request.host_port)
    # print('path', request.path)
    # print('fullpath', request.full_path)
    # print('script-root', request.script_root)
    # print('url', request.url)
    # print('base-url', request.base_url)
    # print('url-root', request.url_root)
    # print('host-url', request.host_url)