5
5
import logging
6
6
import atexit
7
7
8
- from labthings . server . quick import create_app , semantics , find_component , fields
9
- from labthings .views import ActionView , PropertyView
8
+ from labthings import create_app , semantics , find_component , fields
9
+ from labthings .views import ActionView , PropertyView , op
10
10
11
11
12
12
"""
@@ -62,11 +62,13 @@ def average_data(self, n: int):
62
62
class DenoiseProperty (PropertyView ):
63
63
"""Value of magic_denoise"""
64
64
65
+ @op .readproperty
65
66
def get (self ):
66
67
# When a GET request is made, we'll find our attached component
67
68
my_component = find_component ("org.labthings.example.mycomponent" )
68
69
return my_component .magic_denoise
69
70
71
+ @op .writeproperty
70
72
def put (self , new_property_value ):
71
73
# Find our attached component
72
74
my_component = find_component ("org.labthings.example.mycomponent" )
@@ -88,6 +90,7 @@ class QuickDataProperty(PropertyView):
88
90
# Marshal the response as a list of floats
89
91
schema = fields .List (fields .Float ())
90
92
93
+ @op .readproperty
91
94
def get (self ):
92
95
# Find our attached component
93
96
my_component = find_component ("org.labthings.example.mycomponent" )
@@ -111,6 +114,7 @@ class MeasurementAction(ActionView):
111
114
schema = fields .List (fields .Number )
112
115
113
116
# Main function to handle POST requests
117
+ @op .invokeaction
114
118
def post (self , args ):
115
119
"""Start an averaged measurement"""
116
120
@@ -134,7 +138,6 @@ def cleanup():
134
138
# Create LabThings Flask app
135
139
app , labthing = create_app (
136
140
__name__ ,
137
- prefix = "/api" ,
138
141
title = f"My Lab Device API" ,
139
142
description = "Test LabThing-based API" ,
140
143
version = "0.1.0" ,
0 commit comments