Skip to content

olipratt/microstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

microstore

A minimal Python REST microservice datastore, which can be in-memory or JSON file backed.

Runs in-memory only by default, or file-backed if a file name is supplied as a command line argument.

Once running, go to the root URL to explore the API using Swagger UI.

Setup

Requires at least Python 3, tested with 3.5.

Relies on Flask and Flask-RESTPlus for the webserver and REST API, and TinyDB for the JSON database.

To get these clone the repository, open a terminal inside the repository directory and run:

$ pip install -r requirements.txt

Running

Run with -h for full usage options.

$ python microstore.py -h

Run the tests with python test_microstore.py.

Usage

NOTE: All API methods are behind a /api base URL (Swagger UI hides this away at the very bottom of the web page).

You can explore the API using Swagger UI by opening the root URL (that is printed to the terminal when you run the server) in your web browser - see an example image of this in action below.

You can integrate with a client that supports swagger/OpenAPI schemas by just reading the schema directly from /api/schema.

In short though, you can PUT JSON data to /api/apps/<your-app-name-here> as the data key of an object:

{
  "data": {
    "any_data": "you_like_here"
  }
}

and later retrieve it with a GET on the same URL, DELETE it, or replace it with another PUT.

Swagger UI example

Running in Docker

A dockerfile is included to create a containerised microservice - build and run from the repository directory with:

sudo docker build -t microstore:latest .
sudo docker run -p 5000:5000 microstore

Now you can navigate to http://127.0.0.1:5000/ in your web browser to access the SwaggerUI of the container.

Limitations

  • Not production ready. This is designed for simple prototyping use, not for performance at huge load, and does not meet production security requirements.

  • Single threaded. Flask will run single-threaded by default, creating a single synchronous server on a single thread capable of serving only one client at a time, and TinyDB does not support threaded access.

About

A simple REST datastore API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages