Skip to content

A python script that creates a simple server from a given JSON file.

Notifications You must be signed in to change notification settings

jbradforddillon/instant-api-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this?

This is essentially a python implementation of Waldo Jaquith's instant-api, but with a few handy bonus features. It creates a basic RESTful web service using a JSON file as source.

Usage

Unlike it's PHP counterpart, this script doesn't require a running web server with PHP, it uses python's own HTTPServer. Just run it from the command line, like so:

$ ./instant-api.py

To specify the port and/or file to serve, just use the --port and --file attributes, respectively:

$ ./instant-api.py --port 8080 --file source.json

One other minor difference/improvement: this script uses the friendlier/path/format rather than ?query=strings, and can go several levels deep in the JSON, with support for arrays.

Example

Given this JSON:

{
	"colors" : [
		{
			"name" : "Red",
			"hex" : "#FF0000"
		},
		{
			"name" : "Green",
			"hex" : "#00FF00"
		},
		{
			"name" : "Blue",
			"hex" : "#0000FF"
		}
	]
}

You could use this:

http://localhost:8080/colors/1

To retrieve this:

{
	"name" : "Green",
	"hex" : "#00FF00"
}

Licensing and Contact

MIT License. Find me on twitter (@jbradforddillon).

Inspired by Waldo Jaquith

About

A python script that creates a simple server from a given JSON file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages