forked from james-gray/nagini
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py~
60 lines (41 loc) · 1.04 KB
/
main.py~
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import bottle
import os
@bottle.route('/static/<path:path>')
def static(path):
return bottle.static_file(path, root='static/')
@bottle.get('/')
def index():
head_url = '%s://%s/static/head.png' % (
bottle.request.urlparts.scheme,
bottle.request.urlparts.netloc
)
return {
'color': '#00ff00',
'head': head_url
}
@bottle.post('/start')
def start():
data = bottle.request.json
# TODO: Do things with data
return {
'taunt': 'Please change!'
}
@bottle.post('/move')
def move():
data = bottle.request.json
# TODO: Do things with data
return {
'move': 'north',
'taunt': 'battlesnake-python!'
}
@bottle.post('/end')
def end():
data = bottle.request.json
# TODO: Do things with data
return {
'taunt': 'battlesnake-python!'
}
# Expose WSGI app (so gunicorn can find it)
application = bottle.default_app()
if __name__ == '__main__':
bottle.run(application, host=os.getenv('IP', '0.0.0.0'), port=os.getenv('PORT', '8080'))