Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

building REST API in FLASK

Tags:

rest

flask

A very basic question. I have a FLASK app which has postgresql behind it. There are no ORM for this application. All requests are done via SQL psycopg2 interface.

Now I want to expose certain API's from this application. What would be the best way to proceed.

1> Just like: http://flask-peewee.readthedocs.org/en/latest/rest-api.html 2> or can I do one without the ORM. It seems that ORM for an RESTful API is very useful but in this case I have to have a separate database elements and copy data from the postgres model to the ORM.

any suggestion would be welcome.

like image 393
user1102171 Avatar asked May 03 '13 08:05

user1102171


2 Answers

I have a similar setup Flask + Postgres and PsycoPG2. I followed the following tutorials to design and implement the API I handle errors manually and respond with the appropriate HTTP code

http://blog.luisrei.com/articles/rest.html { Design API}

http://blog.luisrei.com/articles/flaskrest.html { Implement API}

like image 53
Fuchida Avatar answered Sep 20 '22 04:09

Fuchida


Looks like Flask-Restless is a better choice. Validations, authentication support are much simpler with it.

like image 44
Devi Avatar answered Sep 19 '22 04:09

Devi