Code Monkey home page Code Monkey logo

pmapi's Introduction

pmgui

PATE Monitor UI code (Flask REST API + Web UI)

This application is intended for Foresail-1 PATE development and testing purposes, but the Web UI (and REST API it uses) can be recycled into mission time EGSE purposes, if the platform team so chooses.

Interfaces

The Flask solution offers two primary interfaces;

  • REST API via /api (TODO: root node output; JSON of routes to /api/*)
  • CSV downloads via /csv (TODO: root node output; CSV of routes to /csv/*)

In addition, system configuration is viewable;

  • Flask app.config listing in /sys/cfg
  • REST API listing in human readable format in /api.html
  • Full interface (routes) JSON listing in /sys/api

The default interface is to serve HTML content via all URI's not matching the paths listed above.

How to Clone with Submodules

 git clone --recurse-submodules https://github.com/jasata/pmapi .

How to update a submodule

# change to the submodule directory
cd ui

# checkout desired branch
git checkout master

# update
git pull

# get back to your project root
cd ..

# now the submodules are in the state you want, so
git commit -am "Pulled down update to /ui"

Alternatively:

git submodule foreach git pull origin master

nginx Configuration

Site file '/etc/nginx/sites-available/default' (or which ever is relevant) needs to reflect uWSGI configuration.

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /srv/nginx-root;
    server_name _;
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/patemon.uwsgi.sock;
    }
}

Issue 'systemctl restart nginx' to apply changes

Instance Configuration

This Flask application holds configuration information in '/srv/nginx-root/instance' directory. Create this directory and 'application.conf' file into it (0440 www-data.www-data):

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Turku University (2018) Department of Future Technologies
# Foresail-1 / PATE Monitor / Middleware (PMAPI)
# Flask application configuration
#
# application.conf - Jani Tammi <[email protected]>
#
#   0.1.0   2018.10.11  Initial version.
#   0.2.0   2018.10.23  Renamed as 'application.conf'
#   0.3.0   2018.10.23  Move version numbers to APIVERSION and APPVERSION.
#
#
# See http://flask.pocoo.org/docs/0.12/config/ for built-in config values.
#
# To generate SECRET_KEY:
# >>> import os
# >>> os.urandom(24)
# b'\xb5R\x8d\x8aZa\x07\x90i\xe5Y\xff\x9e|\xe8p\x0b\x86;\xc3}\xd0\xfc?'
#
import os
import logging

DEBUG                    = True
SESSION_COOKIE_NAME      = 'pmapisession'
SECRET_KEY               = b'\xb5R...'
EXPLAIN_TEMPLATE_LOADING = True
TOP_LEVEL_DIR            = os.path.abspath(os.curdir)
BASEDIR                  = os.path.abspath(os.path.dirname(__file__))


#
# Command table configuration (seconds)
#
COMMAND_TIMEOUT         = 0.5
COMMAND_POLL_INTERVAL   = 0.2


#
# Flask app logging
#
LOG_FILENAME             = 'application.log'
LOG_LEVEL                = 'DEBUG'              # DEBUG, INFO, WARNING, ERROR, CRITICAL


#
# MariaDB configuration
#
MYSQL_DATABASE_HOST      = 'localhost'
MYSQL_DATABASE_PORT      = 3306
MYSQL_DATABASE_USER      = 'dummy'
MYSQL_DATABASE_PASSWORD  = 'dummy'
MYSQL_DATABASE_DB        = 'pmapi'
MYSQL_DATABASE_CHARSET   = 'utf8'	# PyMySQL requires 'utf8', most others want 'utf-8'

#
# SQLite3 configuration
#
SQLITE3_DATABASE_FILE   = 'pmapi.sqlite3'

#
# Flask email
#



# EOF

Generate your personal SECRET_KEY and change database credentials to match your actual credentials.

pmapi's People

Contributors

jasata avatar

Watchers

James Cloos avatar

pmapi's Issues

CSV dialect support

Low priority, as it looks like all the future users prefer the US/comma-separated dialect (which is the default).

Missing testing-session management

Data is supposed to be grouped into testing sessions. These are created and closed by the OBCED, but the middle-ware needs ensure that there is an active testing session before accepting input and it needs to be able to link the entries it makes (commands, operator notes, etc.) into the open testing session (.session_id column in the relevant tables).

This linkage should be automatic and should not be based on rotating the active testing-session ID to WebUI and back.

Flexible field selectors to GET requests

The flexible GET handlers need equally flexible field selector scheme.

  • Adapts to changing number and name of fields.
  • Reports selectors that do have existing counter parts in data (with appropriate HTTP return code).
    (use the existing __get_columns() to build this)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.