-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
38 lines (33 loc) · 832 Bytes
/
server.py
File metadata and controls
38 lines (33 loc) · 832 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
28
29
30
31
32
33
34
35
36
37
38
'''Minehut server Api'''
from .config import *
serv_url = api_url + 'server/'
def getServerID(name: str) -> str:
'''Return server ID by name'''
url = serv_url + name + '?byName=true'
res = req.get(url)
# If request is good
if res.ok:
a = json.loads(res.text)['server']['_id']
else:
a = res
return a
def getInfosbyName(name: str) -> json:
'''Return server infos by name'''
url = serv_url + name + '?byName=true'
res = req.get(url)
# If request is good
if res.ok:
a = json.loads(res.text)
else:
a = res
return a
def getInfosbyID(id: str) -> json:
'''Return server infos by ID'''
url = serv_url + id
res = req.get(url)
# If request is good
if res.ok:
a = json.loads(res.text)
else:
a = res
return a