testapiaddyuming

This commit is contained in:
huangzhenpc
2025-02-27 10:08:58 +08:00
parent c158e42ded
commit dab8c386e8
2 changed files with 51 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
from flask import Flask, request, jsonify
from .config import Config
from .utils import get_latest_emails, get_latest_email_with_code
from .utils import get_latest_emails, get_latest_email_with_code, add_allowed_domain, remove_allowed_domain, get_allowed_domains
def create_app():
app = Flask(__name__)
@@ -25,4 +25,25 @@ def create_app():
return jsonify(email_data)
return jsonify({'error': 'No emails found for this recipient'}), 404
@app.route('/allowed_domains/add', methods=['POST'])
def add_domain():
domain = request.json.get('domain')
if not domain:
return jsonify({'error': 'Domain is required'}), 400
add_allowed_domain(domain)
return jsonify({'message': 'Domain added successfully'}), 201
@app.route('/allowed_domains/remove', methods=['POST'])
def remove_domain():
domain = request.json.get('domain')
if not domain:
return jsonify({'error': 'Domain is required'}), 400
remove_allowed_domain(domain)
return jsonify({'message': 'Domain removed successfully'}), 200
@app.route('/allowed_domains/list', methods=['GET'])
def list_domains():
domains = get_allowed_domains()
return jsonify(domains), 200
return app