Skip to content

Commit 48276b4

Browse files
committed
Update example
1 parent 1e92ef5 commit 48276b4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

docs/source/quickstart/counter.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import time
2-
from labthings_fastapi.thing import Thing
3-
from labthings_fastapi.decorators import thing_action
4-
from labthings_fastapi.descriptors import ThingProperty
2+
import labthings_fastapi as lt
53

64

7-
class TestThing(Thing):
5+
class TestThing(lt.Thing):
86
"""A test thing with a counter property and a couple of actions"""
97

10-
@thing_action
8+
@lt.thing_action
119
def increment_counter(self) -> None:
1210
"""Increment the counter property
1311
@@ -17,23 +15,22 @@ def increment_counter(self) -> None:
1715
"""
1816
self.counter += 1
1917

20-
@thing_action
18+
@lt.thing_action
2119
def slowly_increase_counter(self) -> None:
2220
"""Increment the counter slowly over a minute"""
2321
for i in range(60):
2422
time.sleep(1)
2523
self.increment_counter()
2624

27-
counter = ThingProperty(
25+
counter = lt.ThingProperty(
2826
model=int, initial_value=0, readonly=True, description="A pointless counter"
2927
)
3028

3129

3230
if __name__ == "__main__":
33-
from labthings_fastapi.server import ThingServer
3431
import uvicorn
3532

36-
server = ThingServer()
33+
server = lt.ThingServer()
3734

3835
# The line below creates a TestThing instance and adds it to the server
3936
server.add_thing(TestThing(), "/counter/")

0 commit comments

Comments
 (0)