|
26 | 26 | my_component = PdfComponent() |
27 | 27 | labthing.add_component(my_component, "org.labthings.example.mycomponent") |
28 | 28 |
|
29 | | -# Add routes for the API views we created |
| 29 | +# Make some properties and actions out of our component |
30 | 30 |
|
31 | 31 | labthing.build_property( |
32 | | - my_component, "magic_denoise", "/denoise", description="A magic denoise property", |
| 32 | + my_component, # Python object |
| 33 | + "magic_denoise", # Objects attribute name |
| 34 | + "/denoise", # URL to bind the property to |
| 35 | + description="A magic denoise property", |
33 | 36 | ) |
34 | 37 |
|
35 | 38 | labthing.build_property( |
36 | | - my_component, |
37 | | - "magic_dictionary", |
38 | | - "/dictionary", |
| 39 | + my_component, # Python object |
| 40 | + "magic_dictionary", # Objects attribute name |
| 41 | + "/dictionary", # URL to bind the property to |
39 | 42 | description="A big dictionary of little properties", |
40 | 43 | ) |
41 | 44 |
|
42 | 45 | labthing.build_action( |
43 | | - my_component.average_data, |
44 | | - "/average", |
| 46 | + my_component.average_data, # Python function |
| 47 | + "/average", # URL to bind the action to |
45 | 48 | description="Take an averaged measurement", |
46 | 49 | safe=True, # Is the state of the Thing unchanged by calling the action? |
47 | 50 | idempotent=True, # Can the action be called repeatedly with the same result? |
|
51 | 54 | # Start the app |
52 | 55 | if __name__ == "__main__": |
53 | 56 | from labthings.server.wsgi import Server |
54 | | - |
55 | | - logger = logging.getLogger() |
56 | | - logger.setLevel(logging.DEBUG) |
57 | | - |
58 | | - server = Server(app) |
59 | | - server.run() |
| 57 | + Server(app).run() |
0 commit comments