Pythagoras
Local-run server which acts as a proxy between the moderation server, presentation client and subtitle scripts. This is a single-purpose ugly implementation with its sole purpose being the Richard Stallman lecture at TUL.
Installation
Clone the repository:
git clone git@gordon.zumepro.cz:zumepro/pythagoras.git
Install the dependencies:
sudo pacman -S python-virtualenv
Running the app
Simply execute the run recipe in the Makefile to start the server:
make run
Note that run is also the default recipe. So make
works too.
The run recipe should take care of everything for you... enjoy!
Cleaning up the mess
If you wish to go back to a clean slate just run:
make clean
Packing for production
To make an archive pythagoras.tar.xz
in project root simply run:
make pack
Usage
To connect to the WebSocket for receiving subtitles and messages, simply use the /ws
endpoint, for example like this:
websocat ws://localhost:8000/ws
To push new subtitles onto the server, use the /subtitles
endpoints. There are currently two different ones, and each produces different response type. Here are some examples:
- The first is
/subtitles/update_current
, which serves the purpose of updating the current sentence as it comes. Here is an example:
curl -X POST http://localhost:8000/subtitles/update_current -H "Content-Type: text/plain" -d 'I love pushing '
- The second is
/subtitles/submit_sentence
, which is used to submit the next finished sentence. Here is an example:
curl -X POST http://localhost:8000/subtitles/submit_sentence -H "Content-Type: text/plain" -d 'I love pushing sentences to servers!'
To control the server using commands, use the /control
endpoint, for example like this:
- Poll the peehaitchpea server for the latest message to display:
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "getselectedmessage"}'
- Change the state of auto-polling:
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "setautopolling", "state": false}'
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "setautopolling", "state": true}'
- Set the polling rate to a value (in seconds):
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "autopollingrate", "rate": 10}'
TODO
- Create a command for playing a video (the TED talk RMS likes to play at the beginning of his lecture)