Our server will be implemented in the Python language. In this section, we will go through the script line by line, explaining each as we go along; you can type it in the file or download it from the repository.
So, let's open the MyToolboxServer.py
file and go through its contents.
At the beginning, we need to import files that are necessary for the script to run:
import sys, glob # path for file generated by Apache Thrift Compiler sys.path.append('gen-py') # add path where built Apache Thrift libraries are sys.path.insert(0, glob.glob('thrift-0.9.2/lib/py/build/lib.*')[0])
These are the modules in the gen-py
directory and the thrift-0.9.2
directory (the name depends on the exact Apache Thrift version you use).
Note
Remember to build the library by running the following commands:
cd thrift-0.9.2/lib/py python setup.py build cd ../../..
Next, we need to import some of the modules and functions that will be used in the implemented service. The first line contains...