-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
51 lines (38 loc) · 1.23 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
from flask import Flask, jsonify
from src.repository.apiDB import delete, insert, inventory, item_db
from src.repository.updateDB import inventory_to_object
from src.services.services import Service
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/')
def home():
return "Bienvenido a mi API"
@app.route('/inventario')
def get_items():
items = inventory()
return jsonify(items)
@app.route('/actualizar')
def update():
items = inventory()
inventory_to_object(items)
return "\n\n-----------Inventario actualizado------------\n\n"
@app.route('/actualizar/<name>')
def update_one(name):
new_string = name.replace("+", " ")
item = item_db(new_string)
inventory_to_object(item)
return f"\n\n----------{new_string} ha sido actualizado-----------\n\n"
@app.route('/filter/<name>')
def filter(name):
new_string = name.replace("+", " ")
return item_db(new_string)
@app.route('/reiniciar')
def reset():
delete()
for object in Service.item_list:
item = { 'name': object.getName(), 'sell_in': object.getSellIn(), 'quality': object.getQuality() }
insert(item)
return "\n\n-------------Reinicio exitoso----------\n\n"
if __name__=="__main__":
app.run(debug=True)