Ejemplo n.º 1
0
import logging
import os
import uuid
from datetime import datetime
from pdb import set_trace
from pprint import pprint

import flask
import jsonschema
import requests as HTTP_REQUESTS

from blueprints.resource.blueprint import send_resource

import flask_fat

Journal = self = flask_fat.Journal(__file__)
""" ------------------------------- ROUTES ------------------------------- """


@Journal.BP.route('/%s/add_event' % (Journal.name), methods=['POST'])
def add_subscribe():
    """
        Subscribe to an Add event.
    """
    response = {}
    status = 'nothing'
    code = 200
    body = flask.request.get_json()
    if not body:
        body = flask.request.form
Ejemplo n.º 2
0
#!/usr/bin/python3
import flask
import os
import json
import jsonschema
import requests as HTTP_REQUESTS
from pdb import set_trace

import flask_fat
from llamas.utils import sys_utils
Journal = self = flask_fat.Journal(__file__, url_prefix='/api/v1')

""" ------------------------------- ROUTES ------------------------------- """

@Journal.BP.route('/%s/id' % (Journal.name), methods=['GET'])
def get_id():
    """
        Return nodes ID this API is running on.
    """
    this_node_id = sys_utils.get_hardware_id()
    return flask.make_response(flask.jsonify({
        'id' : this_node_id }), 200)


@Journal.BP.route('/%s/nodes' % (Journal.name), methods=['GET'])
def get_nodes():
    """
        Return [{ 'node_name' : 'node_id' }] list of all currently known nodesids to
    this API.
    """
    endpoints = Journal.mainapp.config['ENDPOINTS']