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

程序名称:kpages

授权协议: MIT

操作系统: 跨平台

开发语言: Python

kpages 介绍

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

[](https://github.com/comger/kpages#how-to-create-kpages-project-version--

063dev)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

[](https://github.com/comger/kpages#how-to-start-kpages-web-

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

[](https://github.com/comger/kpages#how-to-use-context-in-hander-with-

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

[](https://github.com/comger/kpages#how-to-use--uimodule-and-uimethod-in-

kpages)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 官网

https://github.com/comger/kpages

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


MuPlayer 是一款跨平台、轻量级的音频播放解决方案,是百度@音乐前端团队开发维护的浏览端音频播放内核,它基于HTML5
OS FLV 是一个 开源和可嵌入网页的flv播放器。 这个播放器拥有大量的选项可以通过嵌入代码进行设置.
DewPlayer音乐播放器,样式很简单,而且很实用.播放器可以根据自己的喜好改变颜色,也算比较个性化吧.但唯一的不足就是只支持MP3格式的音乐。
JW FLV MEDIA PLAYER是一个开源的在网页上使用的Flash视频、音频以及图片播放器,支持 Sliverlight
Speakker 是一个基于 Web 浏览器的音乐播放器,只提供很多高级播放功能包括播放列表管理和分享。
Player Framework 是一个开源的支持 HTML5 的视频播放器框架,同时也支持 Silverlight 和 Windows Phone
Sewise Player是一款专业的免费网页视频、流播放器,它功能强大,体积小,跨平台,使用方便简洁、随心所欲:
SoundManager 2 利用 HTML5 和 Flash 技术提供了稳定和阔平台的音乐播放功能,只有 10K 的 JS 包。
xPlayer v1.0 特性: 文件大小 9.78kb; 可以自定义皮肤; 3.支持 http 和 rtmp 视频; 4.音量调节,全屏播放,拖拽播放;
XPlayer 豆瓣音乐播放器 特点: 1.自动侦测Douban网页的歌曲 2.Douban网页关闭,歌曲能够继续播放
歌词 插件 最新更新,扩展性能稍微有点提升了, 不多说了,更多敬请查看首页http://luochunzong.sinaapp.com/?p=84
ABPlayerHTML5是一个在HTML5下的弹幕播放器(同步显示视频于评论)实现。类似功能的播放器可以参考基于Flash的MukioPlayer和PADPlayer。
AudioPlayer.js 是一个 jQuery 的插件,实现了 HTML5 的音乐播放器,无需任何图片,实现了响应式布局,支持触摸操作。
替换中国大陆主流视频网站的 Flash 播放器为 HTML5 播放器 使用 Mac 的同学都可能碰到过在线看视频引起机子风扇狂转、机身发烫等情况,这是因为 Flash 占用了过多系统资源的缘故。
AetherPlayer 是一个类CD的轻量HTML5播放器,特别适合博客及个人站点使用。它漂亮得不像……咳,这边吹牛的话就不说了。
专注、极致、智慧,国内外为数不多不依赖开源框架、跨平台(windows/android/iOS)、公网推送(支持rtmp)-播放(支持rtmp/rtsp)业界真正靠谱 的超低延迟。
node-kugou-client 是 Node.js 酷狗客户端。 安装 npm install node-kugou-client 使用 var kugou = require(\"node-kugou-client\");
Youku HTML5 播放器扩展 —— 告别 flash 和广告 关于官方内测 html5 播放器 Firefox ( xpi 直接安装) ( firefox 50.0+)
Chimee 由奇舞团研制的 h5 播放器,它支持 mp4、m3u8、flv 等多种格式。通过插件式开发,能满足业务方快速迭代、灰度发布等要求。让开发者能够轻松快捷地完成视频场景的开发。
OneVideo是一款基于OneBase+UniApp开发的小视频播放移动应用。