Beispiel #1
0
def render(name, **kwargs):
    base_path = os.path.join(ROOT_PATH,'templates')
    template_path = os.path.join(ROOT_PATH,'templates', 'Log_in_and_out')
    lookup = render_jinja(
          [template_path,base_path],
          encoding = 'utf-8',
          filters = {
              'linebreaks' : swmisfilter.linebreaks,
              'strdate': swmisfilter.strdate,
              'strtime': swmisfilter.strtime,
              'filesize': swmisfilter.filesize,
              'markcontent': swmisfilter.markcontent,
              'humantime': swmisfilter.humantime,          
          },
          gvars = { 'swmis_var': BasicInfo() } 
    )
    return lookup.render_template(name,**kwargs)
Beispiel #2
0
          encoding = 'utf-8',
          filters = {
              'linebreaks' : swmisfilter.linebreaks,
              'strdate': swmisfilter.strdate,
              'strtime': swmisfilter.strtime,
              'filesize': swmisfilter.filesize,
              'markcontent': swmisfilter.markcontent,
              'humantime': swmisfilter.humantime,          
          },
          gvars = { 'swmis_var': BasicInfo() } 
    )
    return lookup.render_template(name,**kwargs)

if __name__ == "__main__":
    template_path = os.path.join(ROOT_PATH,'templates', 'Log_in_and_out')
    lookup = render_jinja(
          template_path,
          encoding = 'utf-8',
          filters = {
              'linebreaks' : swmisfilter.linebreaks,
              'strdate': swmisfilter.strdate,
              'strtime': swmisfilter.strtime,
              'filesize': swmisfilter.filesize,
              'markcontent': swmisfilter.markcontent,
              'humantime': swmisfilter.humantime,          
          },
          #gvars = { 'swmis_var': BasicInfo() }
    )
    print dir(lookup._lookup)
    print dir(lookup._lookup.loader)
    print lookup._lookup.loader.searchpath
# initiate render
from utils.render import render_jinja

render_jinja2 = render_jinja(
    searchpath="./web/templates",  #''.join( [root_path,'templates']),   # Set template directory.
    encoding="utf-8",  # Encoding.
)
SITE_URL = "http://110.76.40.188:8003"
REC_URL = "http://127.0.0.1:9003/rec"
# initiate application configuration
SETTINGS = dict(
    cookie_secret="32oEtellGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
    xsrf_cookies=False,
    debug=True,
    login_url="/login",
    logout_url="/logout",
)

# initiate  database configuration
import asyncmongo

db = asyncmongo.Client(
    pool_id="front_dbpool", host="127.0.0.1", port=27017, maxcached=5, maxconnections=10, dbname="learner"
)
SETTINGS["db"] = db

# initiate session configuration
import redis

redis_pool = redis.ConnectionPool(max_connections=5, host="localhost", port=6379)