flask-demo-api/flask_demo_api/routers/key.py

43 lines
1.0 KiB
Python
Raw Normal View History

2024-04-15 02:16:07 +03:00
from flask import Blueprint, jsonify, request
key_bp = Blueprint("key_bp", __name__)
@key_bp.route("/", methods=["POST"])
def past_key():
json_data = request.get_json()
if json_data:
return (
jsonify({"message": "Received JSON data successfully", "data": json_data}),
200,
)
else:
return jsonify({"message": "No JSON data received"}), 400
@key_bp.route("/", methods=["GET"])
def get_key():
json_data = request.args.get("key")
if json_data:
return (
jsonify({"message": "Received JSON data successfully", "data": json_data}),
200,
)
else:
return jsonify({"message": "No JSON data received"}), 400
@key_bp.route("/", methods=["PUT"])
def put_key():
json_data = request.get_json()
if json_data:
return (
jsonify({"message": "Received JSON data successfully", "data": json_data}),
200,
)
else:
return jsonify({"message": "No JSON data received"}), 400