Flask-Restful integration

37 views
Skip to first unread message

Alexandre Viau

unread,
Sep 30, 2014, 11:10:59 PM9/30/14
to pytho...@googlegroups.com
Hello!

I would like to know if flask-restful integration would be possible with WSME?

Is it on the roadmap?


Thanks!

Christophe de Vienne

unread,
Oct 1, 2014, 7:31:50 AM10/1/14
to pytho...@googlegroups.com
Hi Alexandre,

There is already a flask adapter in wsme.

See https://wsme.readthedocs.org/en/latest/integrate.html#flask

Is it what you are looking for ?

Christophe
--
You received this message because you are subscribed to the Google Groups "python-wsme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-wsme...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexandre Viau

unread,
Oct 2, 2014, 8:25:52 PM10/2/14
to pytho...@googlegroups.com
Hello Cristophe!

WSME works well with Flask but not with Flask-restful.

Flask-restful is a widely used extension to write REST APIs with Flask.

I would be glad to provide a non-working flask-restful example if you want.

Alexandre Viau

unread,
Oct 2, 2014, 8:52:17 PM10/2/14
to pytho...@googlegroups.com
I decided to do it already: https://github.com/ReAzem/flask_restful_wsme

As you can see, the post does not work.

Christophe de Vienne

unread,
Oct 3, 2014, 5:32:46 AM10/3/14
to pytho...@googlegroups.com
Hi Alexandre,

I had a look and indeed, your example does not work.

The first (and main) reason is that wsmeext.flask does not support member functions, only free functions. I pushed a patch in review that fix this issue (https://review.openstack.org/#/c/125904/), you can try and pull it, or wait for its integration.

The second reason is that your tests have a few errors that prevent wsme to parse the posted content.
- "Accept" and "Content-Type" headers are missing
- the "data" should have been json-encoded
- The 'post' signature should have been "signature(None, body=Info)"

Cheers,

Christophe

Alexandre Viau

unread,
Oct 3, 2014, 9:24:27 AM10/3/14
to pytho...@googlegroups.com
Hello Cristophe,

This was a very quick fix :)

I have tried your patch and it works as expected. I assume that the other verbs will work too. I will be using this until it's integrated.

Thank you for very much,

Alexandre
Reply all
Reply to author
Forward
0 new messages