kpages

以api 为中心的高性能web 框架
授权协议 MIT
开发语言 Python
所属分类 Web应用开发、 Node.js 扩展
软件类型 开源软件
地区 国产
投 递 者 韩豪
操作系统 跨平台
开源组织
适用人群 未知
 软件概览


kpages

kpages is mini helper for tornado,Contains the address routing management,tornado and app config management, mongodb, redis connection management and other functions; these supports can help you quickly build a web application.

Case

How to create kpages project (version >= 0.6.3.dev)

1. input command: kpages_init.py projectname # projectname: you project name, default is kpages_project
2. set you RequestHandler action dir

How to start kpages web application

python apprun.py  or ./apprun.py
Params
     config=CONFIG  set config for server
     port=PORT      set http port for server
     debug          Debug mode.
     ndebug         No Debug mode.

How to start kpages mq

python service.py  或 ./service.py
Params
     config=CONFIG  set config for server
     port=PORT      set http port for server
     debug          Debug mode.
     ndebug         No Debug mode.
     channel        set channel for redis mq

How to router

restful/index.py(add @url to class , kpages will route url to this handler)

from kpages import url

@url(r'/',0)
@url(r'/home',2)
class HomeHandler(RequestHandler):
    def get(self):
        self.write('hello word')

setting.py

#config for tornado and you app, use __conf__.xxxx to get you config value
ACTION_DIR = 'restful'
DEBUG = True
PORT= 8989

How to use kpages app

from kpages import run

def callback(app):
    pass

if __name__ == '__main__':
    run(callback)

How to use mongo and redis context?

from kpages import get_context, LogicContext,mongo_conv

with LogicContext():
    db = get_context().get_mongo()
    cache = get_context().get_redis()
    lst = list(db['table'].find().limit(10))
    lst = mongo_conv(lst)

How to use context in hander( with session )?

from kpages import ContextHandler

@url(r'/context/demo')
class DemoHandler(ContextHandler,tornado.web.RequestHandler):
    def get(self):
        db = get_context().get_mongo('dbname')
        val = self.session(key)
        self.session(key,val)

test command

run_test(test_city.DemoCase.testprint) :test testprint method
run_test(test_city.DemoCase)           :test methods in DemoCase class
run_test(test_city)                    :test methods in test_city.py
run_test(all )                         :test methods in app's __conf__.UTEST_DIR

pro command

pro_test(test_city.DemoCase.testprint) :profile testprint method
pro_test(test_city.DemoCase)           :profile methods in DemoCase class
pro_test(test_city)                    :profile methods in test_city.py
pro_test(all)                          :profile methods in app's __conf__.UTEST_DIR

How to use uimodule and uimethod in kpages

1. kpages can auto find  Ui_Module's subclass in ACTION_DIR
2. you can use {% module dir_modulename_classname() %} to call Ui Module
Demo Code
    Class Demo(tornado.web.UIModule):
        def render(self,name):
            return self.render('<h1>Hello world:{0}</h1>'.format(name))

Template code
    {% module Demo('kpages') %}


3. @reg_ui_method in ACTION_DIR's files, to apply Ui methods
Demo code

    @reg_ui_method(name='testmethod',intro='demo for ui method')
    def add(self,a,b):
        return a+b

Template code
    {{ add(3,4) }}

  •    这些天很特别,从福建回到了北京,再一次说:北京,我来了!  确定了工作室的一些要素,准备了需要准备的,我的千页,我的kpages 就要诞生了。  一个专注于wap开发的团队,一个为爱心服务的团队 ---千页  祝贺你,我的"千页"。

 相关资料
  • 我们计划构建一个Web应用程序,我希望有人能帮助我们决定是使用Azure App Service还是Azure Function为客户端提供rest API。我们的要求如下。 < li >认证和授权 < Li > Azure SQL和Cosmos DB上的CRUD < li >多区域 < li >每月1亿次API调用 起初,我们打算使用Azure应用服务构建后端。但是在研究了Azure Funct

  • Uragano 旨在提供一个搭建和使用简单的高性能 RPC 框架。Uragano 是基于 netstandard2.0 开发的。Uragano 默认采用 DotNetty 实现远程通信,使用 MessagePack 进行编解码。

  • 我得到的性能下降后,并行化的代码,计算图中心。图比较大,100K顶点。单线程应用程序大约需要7分钟。根据julialang站点(http://julia.readthedocs.org/en/latest/manual/parallel-computing/#man-parallel-computing)的建议,我修改了代码并使用pmap api来并行计算。我开始计算8个过程(julia-p 8c

  • Tornado的web框架(tornado.web)在web.py中实现,主要包括RequestHandler类(本质为对http请求处理的封装)和Application类(是一些列请求处理的集合,构成的一个web-application,源代码注释不翻译更容易理解:A collection of request handlers that make up a web application)。

  • 问题内容: Kotlin是否可以提高性能?有基准测试吗?Kotlin比Java快吗?我在Kotlin网站上找到了这个。https://kotlinlang.org/docs/reference/comparison- to-java.html 谈论语言功能而不是性能。 问题答案: Kotlin生成的字节码与Java非常相似,因此Kotlin代码的性能在大多数情况下与等效Java代码的性能相同。 内