the application was rewritten a bit to be more testable
This commit is contained in:
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user