the application was rewritten a bit to be more testable

This commit is contained in:
Martin
2016-06-28 18:59:20 +02:00
parent 27542b9ebb
commit 2edf0ba8b0
14 changed files with 122 additions and 54 deletions
+12
View File
@@ -1,7 +1,19 @@
# coding=UTF-8
from flask import request, current_app, Response
import unidecode
import re
def check_api_key():
api_keys = current_app.config.get("API_KEYS")
if not api_keys:
return
auth = request.authorization
if not auth or not auth.username in api_keys:
return Response(
'No valid API key provided', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'}
)
def slugify(text):
"""Converts a string to a human-readable url"""