• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python web.WSGIApplication类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python trapdoor.TrapdoorProgram类代码示例发布时间:2022-05-27
下一篇:
Python web.seeother函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap