-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
66 lines (57 loc) · 1.81 KB
/
app.py
File metadata and controls
66 lines (57 loc) · 1.81 KB
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
61
62
63
64
65
66
from CommandHandler import CommandHandler
from Weapon import Weapon
from flask import Flask
from flask import json
from main import weapon_generation
app = Flask(__name__, static_url_path='/static/')
def json_type_response(value):
return app.response_class(
response = value,
status = 200,
mimetype='application/json'
)
@app.route('/')
def index():
return app.send_static_file('help.html')
@app.route('/assault_rifle')
def assault_rifle():
w = Weapon()
w.generate("ASSAULT_RIFLE")
return json_type_response(json.dumps(w.__dict__))
@app.route('/shotgun')
def shotgun():
w = Weapon()
w.generate("SHOTGUN")
return json_type_response(json.dumps(w.__dict__))
@app.route('/sniper_rifle')
def sniper():
w = Weapon()
w.generate("SNIPER_RIFLE")
return json_type_response(json.dumps(w.__dict__))
@app.route('/assault_rifle/<number>')
def assault_rifle_multiple(number):
number = int(number)
weapon_list = []
for i in range(number):
w = Weapon()
weapon_list.append(w)
weapon_list[i].generate("ASSAULT_RIFLE")
return json_type_response(json.dumps([w.__dict__ for weapon_list in weapon_list]))
@app.route('/shotgun/<number>')
def shotgun_multiple(number):
number = int(number)
weapon_list = []
for i in range(number):
w = Weapon()
weapon_list.append(w)
weapon_list[i].generate("SHOTGUN")
return json_type_response(json.dumps([w.__dict__ for weapon_list in weapon_list]))
@app.route('/sniper_rifle/<number>')
def sniper_rifle_multiple(number):
number = int(number)
weapon_list = []
for i in range(number):
w = Weapon()
weapon_list.append(w)
weapon_list[i].generate("SNIPER_RIFLE")
return json_type_response(json.dumps([w.__dict__ for weapon_list in weapon_list]))