Simple command-line client as well
This commit is contained in:
parent
8ff434af75
commit
a028a67180
18
poll
Executable file
18
poll
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import argparse
|
||||
import requests
|
||||
import os
|
||||
import sys
|
||||
|
||||
URL = 'http://localhost:3000'
|
||||
PASSWORD = os.getenv("PASSWORD")
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: poll <QUESTION> [ANSWER 1] [ANSWER 2] ...")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
data = {"question": sys.argv[1], "choices": [sys.argv[x] for x in range(2,len(sys.argv))]}
|
||||
requests.post(URL + "/choices", json = data, headers = {'Authorization': f"Bearer {PASSWORD}"}).raise_for_status()
|
||||
|
Loading…
Reference in New Issue
Block a user