File: examples.rst

package info (click to toggle)
aiocoap 0.4.17-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,040 kB
  • sloc: python: 17,241; makefile: 23; sh: 9
file content (41 lines) | stat: -rw-r--r-- 1,221 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
.. meta::
  :copyright: SPDX-FileCopyrightText: Christian Amsüss and the aiocoap contributors
  :copyright: SPDX-License-Identifier: MIT

Usage Examples
==============

These files can serve as reference implementations for a simplistic server and
client. In order to test them, run ``./server.py`` in one terminal, and use
``./clientGET.py`` and ``./clientPUT.py`` to interact with it.

The programs' source code should give you a good starting point to get familiar
with the library if you prefer reading code to reading tutorials. Otherwise,
you might want to have a look at the :doc:`guidedtour`, where the relevant
concepts are introduced and explained step by step.

.. note:: These example programs are not shipped in library version of aiocoap.
    They are present if you followed the :ref:`installation-development`
    section of the installation instructions; otherwise, you can download them
    from the project website.

Client
------

.. literalinclude:: ../clientGET.py
   :language: python
   :linenos:
   :lines: 11-

.. literalinclude:: ../clientPUT.py
   :language: python
   :linenos:
   :lines: 11-

Server
------

.. literalinclude:: ../server.py
   :language: python
   :linenos:
   :lines: 11-