예제 #1
0
#!/usr/bin/env python
#encoding=UTF-8
import webpy,appapi,appadmin

urls = (
	'/(.*)/', 'redirect',
	'/api', appapi.app_api,  #绑定api子应用
	'/', appadmin.app_admin  #绑定admin子应用
)

app = webpy.application(urls, globals())
#创建Session
session = webpy.session.Session(app, webpy.session.DiskStore('sessions'), initializer={'uid', 'group'})
#关闭调试模式
webpy.config.debug = False

def session_hook():  #通过Session钩子函数绑定session到共用上下文
	webpy.ctx.session = session

app.add_processor(webpy.loadhook(session_hook))

class redirect:  #将以'/'结尾的URL视为无'/'的URL
	def GET(self, path):
		webpy.seeother('/' + path)

if __name__ == '__main__':  #程序主入口
	app.run()
예제 #2
0
import webpy

appKey = '2cn2w4I9YJxO5L1Z'
appSecret = 'CLLX2XroDLYbizIWJjXI2jDL2FtJqCSqWXWVX5iqaSEMEG4Q0G'
token = None
urls = (
    '', "Index",
    'status', 'ApiStatus',
    'admin', 'AdminIndex',
    'admin/login', 'Login',
    'admin/dev', 'DeveloperIndex',
    'admin/dev/reg', 'DeveloperReg',
    'admin/manage', 'ServerManage'
)
app_admin = webpy.application(urls, globals())
render_index = webpy.template.render('usadmin/templates/', base='layout')
render_admin = webpy.template.render('usadmin/templates/admin/', base='../layout')
render_dev = webpy.template.render('usadmin/templates/dev/', base='../layout')


class Index:
    def GET(self):
        return render_index.index()


class ApiStatus:
    def GET(self):
        return render_index.apistatus()

예제 #3
0
        # do the magic
        bookmark = reader.convert(data, False)

        # force browser to show "Save as" dialog.
        web.header('Content-Type', x.myfile.type) # file type
        web.header('Content-disposition',
                   'attachment; filename='+ x.myfile.filename + '.html') 
        model.Increment().increment_users()
        return reader.dump_data(bookmark) # your blob 

class About:
    def GET(self):
        return render.about()

# prod
if __name__ == "__main__":
    print >> sys.stderr, "__name__ == __main__"
    app = web.application(urls, globals())
    app.notfound = notfound
    app.internalerror = internalerror
    app.run()
elif "wsgi" in __name__:
    print >> sys.stderr, "wsgi in__name__"
    application = web.application(urls, globals()).wsgifunc()
    # FIXME
    application.notfound = notfound
    application.internalerror = internalerror
else:
    print >> sys.stderr, "Je ne sais pas quoi faire avec %s" % __name__

예제 #4
0
    #URI格式为 (URL路径)/.(资源类型)
    '/(.+)\.(json|xml|yaml|html|txt)', "ApiAssignment",
)


class ApiAssignment:
    """ApiURI请求分派"""
    def __init__(self):
        self.usServer = UnbarStorageServer(webpy.database)
        # print 'server status => ', self.usServer.getServerStatus()

    def GET(self, url, resType):
        return self.__executApi(url, resType, 'get')

    def POST(self, url, resType):
        return self.__executApi(url, resType, 'post')

    def DELETE(self, url, resType):
        return self.__executApi(url, resType, 'delete')

    def PUT(self, url, resType):
        return self.__executApi(url, resType, 'put')

    def __executApi(self, url, resType, method):
        params = webpy.input()
        datas = webpy.data()
        api_rst = self.usServer.executeApi(url, params=params, datas=datas, resType=resType, method=method)
        return api_rst

app_api = webpy.application(urls, globals())
예제 #5
0
#!/usr/bin/env python
#encoding=UTF-8

import webpy

urls = ('', "Index", 'status', 'ApiStatus')

render = webpy.template.render('usadmin/templates/', base='layout')


class Index():
    def GET(self):
        return render.index()


class ApiStatus():
    def GET(self):
        return render.apistatus()


app_index = webpy.application(urls, globals())
예제 #6
0
#!/usr/bin/env python
#encoding=UTF-8

import webpy

urls = (
	'', "Index",
	'status', 'ApiStatus'
)

render = webpy.template.render('usadmin/templates/', base='layout')

class Index():
	def GET(self):
		return render.index()

class ApiStatus():
	def GET(self):
		return render.apistatus()


app_index = webpy.application(urls, globals())
예제 #7
0
#!/usr/bin/env python
#encoding=UTF-8
from multiprocessing import connection

import webpy

appKey = '2cn2w4I9YJxO5L1Z'
appSecret = 'CLLX2XroDLYbizIWJjXI2jDL2FtJqCSqWXWVX5iqaSEMEG4Q0G'
token = None
urls = ('', "Index", 'status', 'ApiStatus', 'admin', 'AdminIndex',
        'admin/login', 'Login', 'admin/dev', 'DeveloperIndex', 'admin/dev/reg',
        'DeveloperReg', 'admin/manage', 'ServerManage')
app_admin = webpy.application(urls, globals())
render_index = webpy.template.render('usadmin/templates/', base='layout')
render_admin = webpy.template.render('usadmin/templates/admin/',
                                     base='../layout')
render_dev = webpy.template.render('usadmin/templates/dev/', base='../layout')


class Index:
    def GET(self):
        return render_index.index()


class ApiStatus:
    def GET(self):
        return render_index.apistatus()


class Login:
    def GET(self):