@@ -13,7 +13,7 @@ This library is compatible with Python 3.6+.
1313
1414` thingserver ` can be installed via ` pip ` , as such:
1515
16- ``` {.sourceCode . shell}
16+ ``` shell
1717$ pip install thingserver
1818```
1919
@@ -38,7 +38,7 @@ required to expose two properties:
3838
3939First we create a new Thing:
4040
41- ``` {.sourceCode . python}
41+ ``` python
4242light = Thing(
4343 ' urn:dev:ops:my-lamp-1234' ,
4444 ' My Lamp' ,
@@ -54,7 +54,7 @@ this, we need to have a Value object which holds the actual state and
5454also a method to turn the light on/off. For our purposes, we just want
5555to log the new state if the light is switched on/off.
5656
57- ``` {.sourceCode . python}
57+ ``` python
5858light.add_property(
5959 Property(
6060 light,
@@ -72,7 +72,7 @@ The `brightness` property reports the brightness level of the light and
7272sets the level. Like before, instead of actually setting the level of a
7373light, we just log the level.
7474
75- ``` {.sourceCode . python}
75+ ``` python
7676light.add_property(
7777 Property(
7878 light,
@@ -91,7 +91,7 @@ light.add_property(
9191
9292Now we can add our newly created thing to the server and start it:
9393
94- ``` {.sourceCode . python}
94+ ``` python
9595server = WebThingServer(light, port = 8888 )
9696
9797try :
@@ -116,7 +116,7 @@ if the value changes.
116116
117117First we create a new Thing:
118118
119- ``` {.sourceCode . python}
119+ ``` python
120120sensor = Thing(
121121 ' urn:dev:ops:my-humidity-sensor-1234' ,
122122 ' My Humidity Sensor' ,
@@ -131,7 +131,7 @@ Contrary to the light, the value cannot be set via an API call, as it
131131wouldn't make much sense, to SET what a sensor is reading. Therefore, we
132132are creating a ** readOnly** property.
133133
134- ``` {.sourceCode . python}
134+ ``` python
135135sensor.add_property(
136136 Property(
137137 sensor,
@@ -156,7 +156,7 @@ Alternatively, we can create a thread that queries the physical sensor
156156every few seconds. We first remove the readproperty argument from our
157157Property.
158158
159- ``` {.sourceCode . python}
159+ ``` python
160160sensor.add_property(
161161 Property(
162162 sensor,
@@ -177,7 +177,7 @@ sensor.add_property(
177177We then create our looping function to periodically query the sensor and
178178set the property value.
179179
180- ``` {.sourceCode . python}
180+ ``` python
181181self .sensor_update_task = \
182182 get_event_loop().create_task(self .update_level())
183183
0 commit comments