Этот коммит содержится в:
Gautier P 2021-01-26 17:31:04 +01:00
родитель a92db5e8ee
Коммит 711590b809
2 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -96,6 +96,7 @@ def get_app(config):
)
app.route("/api/v1/metadata", ["GET", "OPTIONS"], api_routes.metadata_v1)
app.route("/api/v1/import", ["GET", "OPTIONS"], api_routes.import_v1)
# Index
app.route("/", "GET", lambda: _serve_static_file("index.html"))

Просмотреть файл

@ -16,6 +16,7 @@ import vobject
import flatisfy.data
from flatisfy.models import flat as flat_model
from flatisfy.models.postal_code import PostalCode
from flatisfy import cmds
FILTER_RE = re.compile(r"filter\[([A-z0-9_]+)\]")
@ -496,3 +497,24 @@ def metadata_v1(config):
return {"data": {"last_update": last_update}}
except Exception as exc: # pylint: disable= broad-except
return JSONError(500, str(exc))
def import_v1(config):
"""
API v1 import new flats.
Example::
GET /api/v1/import
:return: The new flats.
"""
if bottle.request.method == "OPTIONS":
# CORS
return {}
try:
flats_id = cmds.import_and_filter(config, False, True)
return {"flats": flats_id}
except Exception as exc: # pylint: disable= broad-except
return JSONError(500, str(exc))