-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
151 lines (109 loc) · 4.74 KB
/
app.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
from flask import Flask, jsonify, request
from getters import npc, boss, bossevent, monsters, items, item, monster, bevent, bss, npc1
from posters import postboss, postbossevent, postitem, postmonster, postnpc
from delup import objdelete, objupdate
app = Flask(__name__) #cinit flask and store in object app
#-------------------------------------------------------- GET METHODS
@app.route('/NPC') #create route
#get function for NPC route
def _npc():
data = npc() #list with dictionary data
return jsonify(data) #return list in json format
@app.route('/NPC/<string:name>')
def _npc1(name):
data = npc1(name)
if len(data) > 0:
return jsonify({"NPC ENCONTRADO":data})
return ('NPC NO ENCONTRADO')
@app.route('/BOSS')
def _boss():
data = boss()
return jsonify(data)
@app.route('/BOSS/<string:name>')
def _bss(name):
data = bss(name)
if len(data) > 0:
return jsonify({"JEFE ENCONTRADO":data})
return ('JEFE NO ENCONTRADO')
@app.route('/BOSSEVENT')
def _bossevent():
data = bossevent()
return jsonify(data)
@app.route('/BOSSEVENT/<string:name>')
def _bosseventunit(name):
data = bevent(name)
if len(data) > 0:
return jsonify({"JEFE DE EVENTO ENCONTRADO":data})
return ('JEFE DE EVENTO NO ENCONTRADO')
@app.route('/MONSTERS')
def _monsters():
data = monsters()
return jsonify(data)
@app.route('/MONSTERS/<string:name>')
def _monster(name):
data = monster(name)
if len(data) > 0:
return jsonify({"MONSTRUO ENCONTRADO":data})
return ('MONSTRUO NO ENCONTRADO')
@app.route('/ITEMS')
def _items():
data = items()
return jsonify(data)
@app.route('/ITEMS/<string:name>')
def _item(name):
data = item(name)
if len(data) > 0:
return jsonify({"ITEM ENCONTRADO":data})
return ('ITEM NO ENCONTRADO')
#------------------------------------------------- END OF GET METHODS
#------------------------------------------------- POST METHODS
@app.route('/NPC', methods=['POST'])
def _postnpc():
data = postnpc(request.json['itemsid'], request.json['name'], request.json['srcimg'], request.json['idd'])
if data:
get = npc()
return jsonify({"NPC INSERTADO CON ÉXITO - NUEVA LISTA": get})
return ('NO SE PUDO INGRESAR EL OBJETO')
@app.route('/BOSS', methods=['POST'])
def _postboss():
data = postboss(request.json['id'], request.json['name'], request.json['mingold'], request.json['maxgold'] , request.json['itemdrop'] , request.json['area'], request.json['srcimg'])
if data:
get = boss()
return jsonify({"BOSS INSERTADO CON ÉXITO - NUEVA LISTA": get})
return ('NO SE PUDO INGRESAR EL OBJETO')
@app.route('/BOSSEVENT', methods=['POST'])
def _postbossevnt():
data = postbossevent(request.json['id'], request.json['name'], request.json['mingold'], request.json['maxgold'] , request.json['itemdrop'] , request.json['area'], request.json['srcimg'])
if data:
get = bossevent()
return jsonify({"BOSS EVENT INSERTADO CON ÉXITO - NUEVA LISTA": get})
return ('NO SE PUDO INGRESAR EL OBJETO')
@app.route('/ITEMS', methods=['POST'])
def _postitem():
data = postitem(request.json['id'], request.json['category'], request.json['name'], request.json['lvlr'], request.json['pricer'] , request.json['finditem'], request.json['srcimg'])
if data:
get = items()
return jsonify({"ITEM INSERTADO CON ÉXITO - NUEVA LISTA": get})
return ('NO SE PUDO INGRESAR EL OBJETO')
@app.route('/MONSTERS', methods=['POST'])
def _postmonster():
data = postmonster(request.json['id'], request.json['name'], request.json['lvl'], request.json['mingold'] , request.json['maxgold'], request.json['dropid'], request.json['area'], request.json['srcimg'])
if data:
get = items()
return jsonify({"ITEM INSERTADO CON ÉXITO - NUEVA LISTA": get})
return ('NO SE PUDO INGRESAR EL OBJETO')
#------------------------------------------------- END OF POST METHODS
#------------------------------------------------- GLOBAL DELETE SPECIFIC OBJECT
@app.route('/<string:subname>/<string:name>', methods=['DELETE'])
def _objdelete(subname, name):
return (objdelete(subname, name))
#------------------------------------------------- END OF GLOBAL DELETE SPECIFIC OBJECT
#------------------------------------------------- GLOBAL UPDATE SPECIFIC OBJECT
@app.route('/<string:subname>/<string:idd>', methods=['PUT'])
def _objupdate(subname, idd):
dat = objupdate(request.json['value1'], request.json['value2'], subname, idd)
return jsonify(dat)
#------------------------------------------------- END OF GLOBAL UPDATE SPECIFIC OBJECT
#if name is executing as principal file
if __name__ == '__main__':
app.run(debug=True, port=3000)