forked from itudb2313/itudb2313
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
61 lines (47 loc) · 1.79 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
from flask import Flask, render_template, request, jsonify, redirect, url_for
from database import Database
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
app.config.from_object("config")
with app.app_context():
db = Database()
app.config["db"] = db
from endpoints.categories import categories_bp
from endpoints.orders import orders_bp
from endpoints.customers import customers_bp
from endpoints.employees import employees_bp
from endpoints.rises import rises_bp
from endpoints.stores import stores_bp
from endpoints.products import products_bp
from endpoints.providers import providers_bp
app.register_blueprint(categories_bp)
app.register_blueprint(orders_bp)
app.register_blueprint(customers_bp)
app.register_blueprint(employees_bp)
app.register_blueprint(rises_bp)
app.register_blueprint(stores_bp)
app.register_blueprint(products_bp)
app.register_blueprint(providers_bp)
@app.route("/")
def hello_world():
return render_template("index.html")
# Example code snippet for json data transfer. Do not remove.
@app.route("/process_json", methods=["POST"])
def process_json():
try:
# Get the JSON data from the request
json_data = request.get_json()
# Access individual fields from the JSON data
rise_id = json_data["rise_id"]
amount_by_percent = json_data["amount_by_percent"]
rise_date = json_data["rise_date"]
rise_state = json_data["rise_state"]
db.insert_rise(rise_id, amount_by_percent, rise_date, rise_state)
# Return a response (you can customize this based on your needs)
return jsonify({"message": "JSON data processed successfully"})
except Exception as e:
# Handle any exceptions or validation errors
return jsonify({"error": str(e)}), 400
if __name__ == "__main__":
app.run()