Added API plugin demo
This commit is contained in:
parent
4cbfe16cc2
commit
be084f6f57
1 changed files with 26 additions and 1 deletions
|
|
@ -1,3 +1,28 @@
|
|||
from openflexure_microscope.api.utilities import parse_payload
|
||||
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue