Улучшен поиск, правки кода.

This commit is contained in:
Jack Stdin
2016-02-02 13:27:42 +03:00
parent 90cae604fa
commit 8088bff07a
13 changed files with 107 additions and 46 deletions

View File

@@ -2,7 +2,7 @@
import json
import logging
from bottle import Bottle
from bottle import Bottle, response
from aore.fias.fiasfactory import FiasFactory
@@ -13,21 +13,29 @@ fias_factory = FiasFactory()
@app.route('/expand/<aoid:re:[\w]{8}(-[\w]{4}){3}-[\w]{12}>')
def expand(aoid):
response.content_type = 'application/json'
return json.dumps(fias_factory.expand(aoid))
@app.route('/normalize/<aoid:re:[\w]{8}(-[\w]{4}){3}-[\w]{12}>')
def normalize(aoid):
response.content_type = 'application/json'
return json.dumps(fias_factory.normalize(aoid))
@app.route('/find/<text>')
@app.route('/find/<text>/<strong>')
def find(text, strong=False):
logging.warning("START")
strong = (strong == "strong")
return json.dumps(fias_factory.find(text, strong))
response.content_type = 'application/json'
res = json.dumps(fias_factory.find(text, strong))
logging.warning("END")
return res
@app.error(404)
def error404(error):
response.content_type = 'application/json'
return json.dumps(dict(error="Page not found"))