forked from Moetto/frisbeer-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
28 lines (21 loc) · 676 Bytes
/
Copy pathapi.py
File metadata and controls
28 lines (21 loc) · 676 Bytes
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
import requests
api_url = "https://ranta.org/frisbeer/API/"
# api_url = "http://localhost:8000/API/"
players = "players"
games = "games"
content_type = {'content-type': 'application/json' }
class APIError(Exception):
pass
class API:
@staticmethod
def get_players():
response = requests.get(api_url + players, headers=content_type)
if not response.ok:
raise APIError("Error in response")
try:
return response.json()
except ValueError as e:
raise APIError(e)
@staticmethod
def create_game(name="asd"):
response = requests.post(api_url + games, headers=content_type, data={})