mirror of
https://github.com/zvx-echo6/recon.git
synced 2026-05-20 06:34:40 +02:00
- YAML-backed saved locations (config/address_book.yaml) - Exact/partial alias matching with case-insensitive lookup - Flask blueprint: /api/address_book/lookup, /api/address_book/list - Geocoder short-circuits Photon when address book has exact match - Test suite for lookup behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
760 B
Python
31 lines
760 B
Python
"""
|
|
RECON Address Book API — Flask Blueprint.
|
|
|
|
GET /api/address_book/lookup?q=<query> — best match or 404
|
|
GET /api/address_book/list — all entries
|
|
"""
|
|
|
|
from flask import Blueprint, request, jsonify
|
|
|
|
from . import address_book
|
|
|
|
address_book_bp = Blueprint('address_book', __name__)
|
|
|
|
|
|
@address_book_bp.route('/api/address_book/lookup')
|
|
def api_address_book_lookup():
|
|
q = request.args.get('q', '').strip()
|
|
if not q:
|
|
return jsonify({'error': 'Missing q parameter'}), 400
|
|
|
|
result = address_book.lookup(q)
|
|
if result is None:
|
|
return '', 404
|
|
|
|
return jsonify(result)
|
|
|
|
|
|
@address_book_bp.route('/api/address_book/list')
|
|
def api_address_book_list():
|
|
entries = address_book.list_all()
|
|
return jsonify(entries)
|