Skip to main content

REST-ful API for Gridder.

Project description

Gridder-REST

A REST-ful API for Gridder. Generate grids or tiles over existing images or as stand-alone images.

Usage

Server

Set up a server and run main.py to be able to receive requests.

Be sure to create a directory named output at the same level as the main script.

NOTE: Gridder-REST stores the uploaded images and the prepared images before sending them back to the user, but no clean up occurs. It is the responsibility of the server to clean up the directory of all the png files created by Gridder-REST.

Client

Send a request containing, at a minimum, the size parameter, to one of the available endpoints (see below) depending on the desired shape of the grid.

See below for a list of allowed and required parameters.

Methods

Requests can be made with two possible methods:

GET

GET requests create brand-new images. In addition to the size parameter, width and height parameters are required to determine the size of the output.

POST

POST requests draw grids over pre-existing images. In addition to the size parameter, the base image to draw on must be provided in the form-data under the base key.

Endpoints

Requests with the allowed methods and parameters must be sent to one of the following endpoints.

All endpoints accept GET and POST methods, with the exception of the / index endpoint, which only accepts GET.

/

Provides basic usage instructions.

/square

A square grid. The size parameter equals the side of the square.

/vline

A grid of vertical lines. The size parameter equals the distance between the lines.

/hline

A grid of horizontal lines. The size parameter equals the distance between the lines.

/vhex

A grid of hexagonal tiles arranged vertically (with top and bottom being flat). The size parameter equals the height of each hex.

/hhex

A grid of hexagonal tiles arranged horizontally (with left and right being flat). The size parameter equals the width of each hex.

Parameters

All parameters are optional except for size and, for GET method, width and height.

Where applicable, measures can be entered in centimetres, millimetres or inches by appending cm, mm or in to the amount.

size

Determines the size of the grid. For details, refer to specific endpoints.

height, width

Height and width of the output image. Only allowed with GET method.

bgcol

Colour of the background of the image. Can be a colour name or hexadecimal colour value like #000000. Only allowed with GET method.

gridcol

Colour of the line used to draw the grid.

padding, pt, pr, pb, pl

Padding around the grid, before the image bounds.

Options for specific padding on the top pt, right pr, bottom pb and left pl margins are available and, if present, have priority over the generic padding option.

line

Line width of the lines used to draw the grid.

name

Name of the output file. If an extension other than png is entered, it is used as part of the file name: the output will always be in png format.

Response codes

200 OK

Everything went as expected and appropriate output was produced.

400 Bad Request

A POST request was made without correctly including the base file.

415 Unsupported Media Type

A POST request was made using a base file in a format unreadable by the backend. Convert the file to a more common format and retry.

422 Unprocessable Entity

One or more required parameter are missing or were provided in unreadable form.

500 Server Error

Something went wrong with the backend. Please contact the author providing details on what you tried so the problem may be fixed, if it's due to a bug.

Project details


Download files

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

Source Distribution

gridder-rest-1.0.1.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

gridder_rest-1.0.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file gridder-rest-1.0.1.tar.gz.

File metadata

  • Download URL: gridder-rest-1.0.1.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4

File hashes

Hashes for gridder-rest-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f8971f5929087f54664eaffb1d1518af217bcefb5bd645649f92b3c5be1b233e
MD5 e0b069656ea98acf5a5cc81c320d01b1
BLAKE2b-256 f864807e86741d7384d7c31f92f829a0e1709c38b5c050bc9dea99cc874bb60e

See more details on using hashes here.

File details

Details for the file gridder_rest-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gridder_rest-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4

File hashes

Hashes for gridder_rest-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5043caacf924a55221dd1ba41dd8ce25dcab983582e8ff9f6cadb16497ff1ce6
MD5 bda2413399dce771dadbf53f096f7a6e
BLAKE2b-256 37a30ddd2ed2b268d644f498fcf8ccf5de2f673711c1521bef284b3409f9d85c

See more details on using hashes here.

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