Added new documentation sections

This commit is contained in:
Joel Collins 2020-01-21 17:05:31 +00:00
parent 03d6a70237
commit aeff3d14cf
8 changed files with 280 additions and 21 deletions

View file

@ -8,12 +8,12 @@ def identify():
"""
microscope = find_component("org.openflexure.microscope")
parent_camera = microscope.camera
parent_stage = microscope.stage
response = "My parent camera is {}, and my parent stage is {}.".format(
parent_camera, parent_stage
response = (
f"My name is {microscope.name}. "
f"My parent camera is {microscope.camera}, "
f"and my parent stage is {microscope.stage}."
)
return response

View file

@ -2,7 +2,7 @@ from labthings.server.extensions import BaseExtension
from labthings.server.find import find_component
from labthings.server.view import View
from labthings.server.decorators import use_args
from labthings.server.decorators import use_body
from labthings.server import fields
## Extension methods
@ -45,10 +45,10 @@ class ExampleIdentifyView(View):
class ExampleRenameView(View):
# Expect a request parameter called "name", which is a string. Pass to argument "args".
@use_args({"name": fields.String(required=True, example="My Example Microscope")})
def post(self, args):
# Look for our "name" parameter in the request arguments
new_name = args.get("name")
@use_body(fields.String(required=True, example="My Example Microscope"))
def post(self, body):
# Look for our new name in the request body
new_name = body
# Find our microscope component
microscope = find_component("org.openflexure.microscope")