Added API plugin demo

This commit is contained in:
Joel Collins 2018-12-11 17:22:01 +00:00
parent 4cbfe16cc2
commit be084f6f57

View file

@ -1,3 +1,28 @@
from openflexure_microscope.api.utilities import parse_payload
from openflexure_microscope.api.v1.views import MicroscopeView from openflexure_microscope.api.v1.views import MicroscopeView
ENDPOINTS = {} from flask import request, Response
import logging
class PluginTestAPI(MicroscopeView):
def get(self):
data = self.microscope.plugin.test1.run() # Call a method from our plugin
return Response(data)
def post(self):
# Get payload
state = parse_payload(request)
logging.debug(state)
# Handle absolute positioning
if 'data' in state: # If value is given in payload JSON
data = str(state['data']) # Process and store that value
return Response(data)
ENDPOINTS = {
'test1': PluginTestAPI
}