# -*- coding: utf-8 -*- import json import logging from bottle import Bottle, response from aore.fias.fiasfactory import FiasFactory logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO) app = Bottle() fias_factory = FiasFactory() @app.route('/expand/') def expand(aoid): response.content_type = 'application/json' return json.dumps(fias_factory.expand(aoid)) @app.route('/normalize/') def normalize(aoid): response.content_type = 'application/json' return json.dumps(fias_factory.normalize(aoid)) @app.route('/find/') @app.route('/find//') def find(text, strong=False): strong = (strong == "strong") response.content_type = 'application/json' return json.dumps(fias_factory.find(text, strong)) @app.error(404) def error404(): response.content_type = 'application/json' return json.dumps(dict(error="Page not found"))