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滚动条不会出现在JList上   java JOGL监视器GPU内存   java为什么要使用RecyclerView onDraw延迟   java定制Oppo Reno 2 Z CPH1951(手机型号)的固件(闪存文件)   java自定义线程池执行器   java如何解决发布版本中重复的jar条目[com/安卓/volley/R.class]?   java如何使用Bukkit API触发事件?   java在blazemeter jmeter RTE插件中使用ctrl+w输入   C#/Visual Studio的java JDT等价物   java为什么当maxread值很大而收到的消息数量很小时,卡夫卡消费者会无限期消费?   java游戏2。x:包含模板列表的绑定模型   带压缩的java日志旋转   运行时。exec用java运行程序读取它正在做什么