Skip to content
Snippets Groups Projects

Skeleton Web App

Overview

This module implements a skeleton Flask-based webservice.

The webservice is communicates with clients over HTTP. Responses to valid requests are returned as JSON messages. The server will therefore return an error unless application/json is in the Accept request header field.

HTTP communication and JSON grammar details are beyond the scope of this document. Please refer to RFC 2616 and www.json.org for more details.

Configuration

This app allows specification of a few example configuration parameters. These parameters should stored in a file formatted similarly to config.json.example, and the name of this file should be stored in the environment variable CONFIG_FILENAME when running the service.

Running this module

This module has been tested in the following execution environments:

  • As an embedded Flask application. For example, the application could be launched as follows:
$ export FLASK_APP=app.py
$ export CONFIG_FILENAME=config.json
$ flask run
  • As an Apache/mod_wsgi service.

    • Details of Apache and mod_wsgi configuration are beyond the scope of this document.
  • As a gunicorn wsgi service.

    • Details of gunicorn configuration are beyond the scope of this document.

Protocol Specification

The following resources can be requested from the webservice.

resources

Any non-empty responses are JSON formatted messages.

/data/version

  • /version

The response will be an object containing the module and protocol versions of the running server and will be formatted as follows:

{
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
          "api": {
              "type": "string",
              "pattern": r'\d+\.\d+'
          },
          "module": {
              "type": "string",
              "pattern": r'\d+\.\d+'
          }
      },
      "required": ["api", "module"],
      "additionalProperties": False
  }

/test/test1

The response will be some json data, as an example ...