以api 为中心的高性能web 框架 kpages

码农软件 · 软件分类 · Node.js 扩展 · 2019-04-16 18:28:00

软件介绍


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) }}

本文地址:https://codercto.com/soft/d/3726.html

以匠心,致设计:网易 UEDC 用户体验设计

以匠心,致设计:网易 UEDC 用户体验设计

网易用户体验设计中心 / 电子工业出版社 / 2018-8 / 95.00元

为什么网易云音乐的体验流畅细腻、富有温度?为什么网易严选App的UI设计让人感到温馨、舒适?为什么网易蜗牛读书App的界面设计让用户爱不释手…… 《以匠心,致设计:网易 UEDC 用户体验设计》是网易用户体验设计团队对自身过去的设计思考的精心总结,最大程度还原了网易产品背后的设计故事,内容涵盖设计基础、设计实践、方法思考、成长指南四章,借助网易产品设计的实际案例具体讲述了设计师日常工作中不可......一起来看看 《以匠心,致设计:网易 UEDC 用户体验设计》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具