Thursday, February 14, 2013

Python REST Framework FLASK

Flask is a very lightweight REST framework for python, here is a very basic tutorial to get started.

install Flask,
pip install flask,
image
then create one module to test the flask.

hello world test,
image
then run the web server,
image
now http://localhost:8000/, you will see the hellofalsk page,
image

test to list folders and return as Json,
image
here we put prefix in the url template. in the method we can assess the url passed from user side.
image

test to get the request information, like the user-agent. just import the global request.
image

image

No comments:

 
Locations of visitors to this page