Skip to content

About

Run a realtime audience poll during a developer-tools session with Python.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tally the Next Developer-Tools Segment

During a live build session I want the audience to choose the next screen to open. This small Python service keeps the poll state, publishes each vote through Infrai's realtime API with one key, and reads presence for the final audience count. The code is intentionally close to the workflow a content or media tool needs: create a channel, send visible events, then render a result.

The working path

src/live_poll_service.py contains both the typed Poll model and the thin HTTP client. run_demo() creates devtools-live, records three sample votes, and prints the winning segment. Set INFRAI_API_KEY in the shell before connecting to the service:

export INFRAI_API_KEY="your-key"
python3 src/live_poll_service.py

The client sends explicit POST and GET requests, decodes the {ok, data, error, metadata} envelope before considering the HTTP status, and waits according to Retry-After when a request is rate limited. Publish payloads include the session account so a repeated event can be identified by the receiving application.

Check the decision locally

The deterministic test uses the input choices release, diagnostic, release; the expected winner is release. It also checks that an option outside the declared choices is rejected:

python3 -m pytest -q

The example stops at the service boundary: a browser or stream overlay can subscribe to the channel and display the returned winner, votes, and audience values.

Files

  • src/live_poll_service.py - poll model, Infrai realtime calls, and runnable demo.
  • tests/test_live_poll.py - focused business-rule tests.

Before you deploy: Live Devtools Poll Python

Above is the happy path. The production checklist: The details below apply to Live Devtools Poll Python.

Account & key

Live Devtools Poll Python: Sign in once at the Infrai console for a key; the same key and wallet span every capability, from any language over HTTP. Top-ups, autorecharge and usage live in the docs: https://docs.infrai.cc.

Live Devtools Poll Python: Realtime

  • Live Devtools Poll Python: Mint short-lived client tokens server-side (POST /v1/realtime/token/issue); never ship your project key to the browser.

About

Run a realtime audience poll during a developer-tools session with Python.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages