當前位置: 首頁>>代碼示例>>Python>>正文


Python web.WSGIApplication類代碼示例

本文整理匯總了Python中transwarp.web.WSGIApplication的典型用法代碼示例。如果您正苦於以下問題:Python WSGIApplication類的具體用法?Python WSGIApplication怎麽用?Python WSGIApplication使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了WSGIApplication類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: WSGIApplication

A WSGI application entry.
'''

import logging; logging.basicConfig(level=logging.INFO)

import os

from transwarp import db
from transwarp.web import WSGIApplication, Jinja2TemplateEngine

from config import configs

# init db:
db.create_engine(**configs.db)

# init wsgi app:
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'))

wsgi.template_engine = template_engine

import urls

wsgi.add_interceptor(urls.user_interceptor)
wsgi.add_interceptor(urls.manage_interceptor)
wsgi.add_module(urls)

if __name__ == '__main__':
    wsgi.run(8000)
開發者ID:Spacebody,項目名稱:ProfStudSystem,代碼行數:30,代碼來源:wsgiapp.py

示例2: WSGIApplication

    if delta < 60:
        return u'1分鍾前'
    if delta < 3600:
        return u'%s分鍾前' % (delta // 60)
    if delta < 86400:
        return u'%s小時前' % (delta // 3600)
    if delta < 604800:
        return u'%s天前' % (delta // 86400)
    dt = datetime.fromtimestamp(t)
    return u'%s年%s月%s日' % (dt.year, dt.month, dt.day)

# init db:
db.create_engine(**configs.db)

# init wsgi app:
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'))
template_engine.add_filter('datetime', datetime_filter)

wsgi.template_engine = template_engine

import urls

wsgi.add_interceptor(urls.user_interceptor)
wsgi.add_interceptor(urls.manage_interceptor)
wsgi.add_module(urls)

if __name__ == '__main__':
    wsgi.run(9000, host='0.0.0.0')
else:
開發者ID:akicqi,項目名稱:python_mini_blog,代碼行數:31,代碼來源:wsgiapp.py

示例3: WSGIApplication

sys.setdefaultencoding('utf8')
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'site-packages.zip'))

import logging; logging.basicConfig(level=logging.INFO)

from transwarp import db
from transwarp.web import WSGIApplication, Jinja2TemplateEngine

from config import configs
from filters import datetime_filter, rssdate_filter, markdown_filter

# 初始化數據庫
db.create_engine(**configs['db'])

# 創建一個WSGIApplication
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

# 初始化Jinja2模版引擎
template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'))

# 把filter添加到jinja2,filter本身是一個函數對象
template_engine.add_filter('datetime', datetime_filter)
template_engine.add_filter('rssdate', rssdate_filter)
template_engine.add_filter('html', markdown_filter)

wsgi.template_engine = template_engine

# 加載url中的函數
import urls
wsgi.add_interceptor(urls.user_interceptor)
wsgi.add_interceptor(urls.manage_interceptor)
開發者ID:zhu327,項目名稱:blog,代碼行數:31,代碼來源:wsgiapp.py

示例4: int

    delta = int(time.time() - t)
    if delta < 60:
        return u'1分鍾前'
    if delta < 3600:
        return u'%s分鍾前' % (delta // 60)
    if delta < 86400:
        return u'%s小時前' % (delta // 3600)
    if delta < 604800:
        return u'%s天前' % (delta // 86400)
    dt = datetime.fromtimestamp(t)
    return u'%s年%s月%s日' % (dt.year, dt.month, dt.day)

# init db:
db.create_engine(**configs.db)

# init wsgi app:
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'))
template_engine.add_filter('datetime', datetime_filter)

wsgi.template_engine = template_engine

import urls

wsgi.add_interceptor(urls.user_interceptor)
wsgi.add_interceptor(urls.manage_interceptor)
wsgi.add_module(urls)

if __name__ == '__main__':
    wsgi.run(9000, host='0.0.0.0')
開發者ID:ixjx,項目名稱:python-blog,代碼行數:31,代碼來源:wsgiapp.py

示例5: datetime_filter

def datetime_filter(t):
    delta = int(time.time() - t)
    if delta < 60:
        return u'一分鍾前'
    elif delta < 3600:
        return u'%s分鍾前' %( delta // 60)
    elif delta < 86400:
        return u'%s小時前' %( dalta // 3600)
    elif delta < 604800:
        return u'%s天前' %( delta // 86400)
    dt = datetime.fromtimestamp(t)
    return u'%s年%s月%s日' % (dt.year,dt.month,dt.day)

# init db
db.create_engine(**configs.db)

#init wsgi app
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'))
template_engine.add_filter('datetime', datetime_filter)

wsgi.template_engine = template_engine

import urls

wsgi.add_module(urls)

if __name__ == '__main__':
    wsgi.run(9000)
開發者ID:cs50Mu,項目名稱:wonderland,代碼行數:30,代碼來源:wsgiapp.py

示例6: WSGIApplication

#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'Michael Liao'

'''
A WSGI application entry.
'''

import urls

from transwarp.web import WSGIApplication


# init wsgi app:
wsgi = WSGIApplication()

wsgi.add_module(urls)

if __name__ == '__main__':
    wsgi.run(8080)
else:
    application = wsgi.get_wsgi_application()
開發者ID:huangsongyan,項目名稱:pythondemo,代碼行數:23,代碼來源:webapi.py

示例7: __call__

    def __call__(self, path, model):
        return "<!-- override this method to render template -->"


class Jinja2TemplateEngine(TemplateEngine):
    def __init__(self, templ_dir, **kw):
        from jinja2 import Environment, FileSystemLoader

        if not "autoescape" in kw:
            kw["autoescape"] = True
        self._env = Environment(loader=FileSystemLoader(templ_dir), **kw)

    def add_filter(self, name, fn_filter):
        self._env.filters[name] = fn_filter

    def __call__(self, path, model):
        return self._env.get_template(path).render(**model).encode("utf-8")


# init wsgi app:
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))
template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates"))
wsgi.template_engine = template_engine
wsgi.add_module(urls)  # 把url中的路徑-函數,打包成映射關係,路徑:route,route是從原python函數


if __name__ == "__main__":
    wsgi.run(9000, host="0.0.0.0")  # 自己運行,使用內置的web服務器
else:
    application = wsgi.get_wsgi_application()  # 傳遞給其他模塊
開發者ID:hxcai,項目名稱:server-1,代碼行數:30,代碼來源:wsgiapp.py

示例8: WSGIApplication

import logging

logging.basicConfig(level=logging.INFO)

import os

from transwarp import db
from transwarp.web import WSGIApplication, Jinja2TemplateEngine

from config import configs

# init db:
db.create_engine(**configs.db)

# init wsgi app:
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates"))

wsgi.template_engine = template_engine

# load module
import urls

wsgi.add_module(urls)

# jinja2 filter
import time, datetime


def datetime_filter(t):
開發者ID:zhongsihang,項目名稱:blog-python-app,代碼行數:31,代碼來源:wsgiapp.py

示例9: datetime_filter

import os, time
from datetime import datetime
from transwarp import db
from transwarp.web import WSGIApplication, Jinja2TemplateEngine
from config import configs

def datetime_filter(t):
	delta = int(time.time() - t)
	if delta < 60:
		return u'1分鍾前'
		if delta < 3600:
			return u'%s分鍾前' % (delta // 60)
			if delta < 86400:
				return u'%s小時前' % (delta // 3600)
				if delta < 604800:
					return u'%s天前' % (delta // 86400)
					dt = datetime.fromtimestamp(t)
					return u'%s年%s月%s日' % (dt.year, dt.month, dt.day)
# init db:
db.create_engine(**configs.db)
# init wsgi app:
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))
template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'))
template_engine.add_filter('datetime', datetime_filter)
wsgi.template_engine = template_engine
import urls
wsgi.add_module(urls)
if __name__ == '__main__':
	wsgi.run(9000, host='0.0.0.0')
else:
	application = wsgi.get_wsgi_application()
開發者ID:WilliamLin1990,項目名稱:report,代碼行數:31,代碼來源:wsgiapp.py

示例10: WSGIApplication

A WSGI application entry.
'''

import logging; logging.basicConfig(level=logging.INFO)

import os

from transwarp import db
from transwarp.web import WSGIApplication, Jinja2TemplateEngine

from config import configs

# init db:
db.create_engine(**configs.db)

# init wsgi app:
wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'))

wsgi.template_engine = template_engine

import urls

wsgi.add_module(urls)

if __name__ == '__main__':
    wsgi.run(9000)
else:
    import sae
    application = sae.create_wsgi_app(wsgi.get_wsgi_application(debug=False))
開發者ID:alphapua,項目名稱:webapp,代碼行數:31,代碼來源:wsgiapp.py


注:本文中的transwarp.web.WSGIApplication類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。