Ripozo的一个扩展,它将hateoas/rest/hypermedia api带到烧瓶中

flask-ripozo的Python项目详细描述


烧瓶Ripozo

test statustest coverageDocumentation Status

这个包为ripozo提供了一个调度器,这样您就可以 把里波佐和烧瓶整合在一起。就像所有的调度员一样 获取请求参数并将它们适当地路由到 处理的各种资源。

查看tutorial.

或者ripozo documentation.

示例

这个例子描述了一个最小的烧瓶ripozo应用程序。

fromflaskimportFlaskfromflask_ripozoimportFlaskDispatcherfromripozo.decoratorsimportapimethodfromripozo.adaptersimportSirenAdapter,HalAdapterfromripozo.resourcesimportResourceBaseclassHelloWorldViewset(ResourceBase):resource_name='myresource'# The name of the resource.  This will be appended to# the _namespace to complete the url.# The decorator indicates that the base url will be used# and that it will be registered for GET requests# a GET request to /api/myresource would be dispatched to this# method and handled here@apimethod(methods=['GET'])defhello(cls,request,*args,**kwargs):faked_response_properties={'content':'hello world'}returncls(properties=faked_response_properties)# Create the flask applicationapp=Flask(__name__)# Create the dispatcherdispatcher=FlaskDispatcher(app,url_prefix='/api')# Specify the valid response typesdispatcher.register_adapters(SirenAdapter,HalAdapter)# This will register all of the apimethod decorated methods in# this class specified.  In this case it adds the /api/myresource GET# route to the applicationdispatcher.register_resources(HelloWorldViewset)if__name__=='__main__':app.run()# Run the app

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何创建单例枚举映射?   java如何在Android视频视图中添加Cookie(标题)以支持旧版本的Android,至少到jellybean为止   Java Swing从单击中获取X,Y   java不兼容类型:int不能转换为数组中的字符串   用于写入文件的java相对文件路径   在Java中使用COLT求解线性系统的性能   java谁生成了在服务存在的进程中运行的主线程和循环器?   JAVARuntimeException:java。ClassCastException:java。lang.Long不能转换为java。串   java检查数据库连接处于活动状态   java Spring多对多未保存在表单提交上   java向Maven添加系统依赖项   爪哇和C++中迭代器的区别是什么?   java Getting“类型不匹配:在实例化映射列表时,无法将ArrayList<HashMap<String,String>>转换为List<Map<String,String>>”   javavaadin表容器并发修改   java错误膨胀类安卓。支持v7。小装置。FitWindowsFrameLayout   java如何在没有打开GL ES的情况下设置对象动画?