Добавлено простое WSGI (Bottle)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -6,4 +5,3 @@ reload(sys)
|
||||
cwd = os.getcwd()
|
||||
sys.path.append(cwd)
|
||||
sys.setdefaultencoding("utf-8")
|
||||
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
|
||||
|
||||
@@ -14,7 +14,7 @@ class SphinxSearch:
|
||||
def __init__(self, db):
|
||||
self.delta_len = 2
|
||||
|
||||
self.rating_limit_soft = 0.4
|
||||
self.rating_limit_soft = 0.6
|
||||
self.rating_limit_soft_count = 6
|
||||
self.word_length_soft = 3
|
||||
|
||||
@@ -22,7 +22,7 @@ class SphinxSearch:
|
||||
self.rating_limit_hard_count = 3
|
||||
|
||||
self.default_rating_delta = 2
|
||||
self.regression_coef = 0.04
|
||||
self.regression_coef = 0.01
|
||||
|
||||
self.db = db
|
||||
self.client_sugg = sphinxapi.SphinxClient()
|
||||
|
||||
33
aore/phias.py
Normal file
33
aore/phias.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import json
|
||||
import logging
|
||||
|
||||
from bottle import Bottle
|
||||
|
||||
from aore.fias.fiasfactory import FiasFactory
|
||||
|
||||
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
|
||||
app = Bottle()
|
||||
fias_factory = FiasFactory()
|
||||
|
||||
|
||||
@app.route('/expand/<aoid:re:[\w]{8}(-[\w]{4}){3}-[\w]{12}>')
|
||||
def expand(aoid):
|
||||
return json.dumps(fias_factory.expand(aoid))
|
||||
|
||||
|
||||
@app.route('/normalize/<aoid:re:[\w]{8}(-[\w]{4}){3}-[\w]{12}>')
|
||||
def normalize(aoid):
|
||||
return json.dumps(fias_factory.normalize(aoid))
|
||||
|
||||
|
||||
@app.route('/find/<text>')
|
||||
@app.route('/find/<text>/<strong>')
|
||||
def find(text, strong=False):
|
||||
strong = (strong == "strong")
|
||||
return json.dumps(fias_factory.find(text, strong))
|
||||
|
||||
|
||||
@app.error(404)
|
||||
def error404(error):
|
||||
return json.dumps(dict(error="Page not found"))
|
||||
Reference in New Issue
Block a user