V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
EricNirvana
V2EX  ›  Python

自己撸了一个 web 框架,目标是快速开发 restful 风格的 web api

  •  1
     
  •   EricNirvana · 2016-05-08 21:55:58 +08:00 · 2817 次点击
    这是一个创建于 2881 天前的主题,其中的信息可能已经有所发展或是发生改变。

    自己撸了一个 web 框架,项目名字是 Puck ,玩过 dota 的都知道~
    目标是快速开发 restful 风格的 web api ,地址 https://github.com/EricQAQ/Puck

    目前项目开发时间比较短,很多功能还有 bug ,文档还没有弄出来,只有简单的 example ,但是代码的注释比较齐全。

    求大神指导,互相学习~

    该项目的依赖包几乎只有 python 自带的标准库,只有少量的外部依赖~

    语法结构参考了 flask ,借鉴了 flask 的 context 机制

    使用 Puck 很方便:

    from puck import Puck, api_response, request
    
    app = Puck()
    
    @app.route('/', methods=['GET'])
    def hello():
        return api_response(
            data={
                'test': 'hello world!'
            }
        )
    
    if __name__ == '__main__':
        app.run()
    
    

    这样就可以返回一个 json 对象了~

    6 条回复    2016-05-14 23:35:09 +08:00
    EricNirvana
        1
    EricNirvana  
    OP
       2016-05-10 10:31:05 +08:00
    Version 0.1.2 已发布~

    安装: pip install pucks

    教程在 https://github.com/EricQAQ/Puck/wiki

    欢迎提 bug~
    pierre1994
        2
    pierre1994  
       2016-05-13 15:14:08 +08:00
    弱弱问一下,权限认证和加密传输是否涉及额
    hjcpnr
        3
    hjcpnr  
       2016-05-14 12:22:26 +08:00
    不错不错,楼主,我也撸了一个框架,有兴趣一起交流啊!
    https://bitbucket.org/hjcpn/webuilder
    EricNirvana
        4
    EricNirvana  
    OP
       2016-05-14 14:27:23 +08:00
    @pierre1994 你指的权限认证是类似登陆,然后是接口访问权限吗,其实可以通过种 cookie 的方式解决?
    EricNirvana
        5
    EricNirvana  
    OP
       2016-05-14 14:29:54 +08:00
    @hjcpnr 恩恩 互相学习~ 另外 在 0.1.3 里面我支持了 restful 风格的接口的编写,可以按照自己的需求规定参数及其类型,详情可以看 0.1.3 里面的 example~
    Fing
        6
    Fing  
       2016-05-14 23:35:09 +08:00
    感谢好厉害的样子,已 fork
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1223 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 18:05 · PVG 02:05 · LAX 11:05 · JFK 14:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.