Skip to main content

An API built on Flask-RESTful that returns with the names of all the states in USA.

Project description

##StatesofUSA##

A REST API to return names of the states of U.S.A. This API is built on Flask-restful.

Follow the steps below to create a REST app on your Linux machine.

Make sure you have installed python-pip First create a virtial environment using pip.

$ sudo apt-get install python-virtualenv

Create an evironment of your own. Use a separate folder where you want to have the virtual setup. Here I’m creating a folder _statesofusa_env_ then a _venv_ within.

$ mkdir statesofusa_env $ cd statesofusa_env $ virtualenv venv

New python executable in venv/bin/python Installing distribute…………done.

Now enter the virtual environment

$ . venv/bin/activate

Once this is done, you will be inside the virtual mode. (notice the prompt shows a venv environment) Now install Flask and Flask-restful

$ pip install Flask $ pip install flask-restful

Once you have done that. All your requirements are ready. You now have to get the [StatesofUSA](https://github.com/ishammi/StatesofUSA/) git repository.

$ git clone git@github.com:<your_git_username>/StatesofUSA.git

Now to run RESTapi server. Run the _main.py_ file

$ cd statesofusa/ $ python main.py * Running on http://127.0.0.1:5000/ * Restarting with reloader

Congratulations.. Your Flask REST server is up and running in the local machine on port 5000. However the API is routed to the URL http://127.0.0.1:5000/states/ For convinience, we have hard coded few authorization parameters. Use the token ‘38c50d14-436b-4e3e-b447-e2e9334fea1a’ to hit the API from outside the virtual environment. Here’s an example

$ curl -H “Authorization: token 38c50d14-436b-4e3e-b447-e2e9334fea1a” –data “page=1&items_per_page=10” http://127.0.0.1:5000/states/

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

StatesofUSA-0.1-py2.7.egg (14.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page