49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
from flask import Blueprint, request, jsonify
|
|
# from services.rokky import ones
|
|
from API.rok import get_order_content
|
|
import logging
|
|
|
|
|
|
main = Blueprint("main", __name__)
|
|
|
|
@main.route("/")
|
|
def index():
|
|
return "Hello wstkeys!!!"
|
|
|
|
|
|
|
|
@main.route("/orders", methods=["POST", "GET"])
|
|
def index1():
|
|
# Получаем все GET-параметры
|
|
params = request.args.to_dict()
|
|
|
|
# Просто выводим на экран (в ответ клиенту)
|
|
return f"Received params: {params}", 200
|
|
|
|
return "Hello GET"
|
|
|
|
@main.route("/sales", methods=["POST", "GET"])
|
|
def index2():
|
|
return "Hello GET"
|
|
|
|
|
|
@main.route("/newOrder", methods=["POST"])
|
|
def new_order():
|
|
if not request.is_json:
|
|
return jsonify({"error": "Invalid content type"}), 400
|
|
|
|
data = request.get_json()
|
|
print(data)
|
|
order_id = data.get("orderId")
|
|
if order_id is None:
|
|
return jsonify({"error": "orderId is required"}), 400
|
|
|
|
if not isinstance(order_id, int):
|
|
return jsonify({"error": "orderId must be int"}), 400
|
|
|
|
# TODO: обработка заказа
|
|
print(f"New order received: {order_id}")
|
|
logging.warn(get_order_content(order_id))
|
|
logging.warn(f"newOrder: {order_id}")
|
|
|
|
return jsonify({"status": "ok"}), 200 |