Esempio n. 1
0
from flask_limiter import Limiter
from typing import Any, Dict, Union
from translation_providers.ESVApiTranslationProvider import ESVApiTranslationProvider
from text_providers.Nestle1904LowfatProvider import Nestle1904LowfatProvider
from text_providers.TextProvider import TextProvider
from werkzeug.http import HTTP_STATUS_CODES
from AnoixoError import AnoixoError, ProbableBugError, TooManyRequestsError
from TextQuery import TextQuery
from translation_providers.TranslationProvider import TranslationProvider

app = Flask(__name__)
CORS(app)

text_providers: Dict[str, TextProvider] = {'nlf': Nestle1904LowfatProvider()}
translation_providers: Dict[str, TranslationProvider] = {
    'esv': ESVApiTranslationProvider()
}


def _get_address_for_request():
    """
    In the default Nginx configuration for Anoixo, this Flask server is behind a proxy, and Nginx sets a 'X-Real-Ip'
    header with the original remote address whenever it forwards requests to Flask.

    If that header is not present (e.g. in a testing/development situation where a proxy server isn't set up), we are
    presumably not behind a proxy and can just use the original remote address.

    Please note this system means that IP addresses can be easily spoofed if the app is deployed NOT behind a proxy! All
    the spoofer would need to do is set a bogus X-Real-Ip header. So please make sure to deploy Anoixo behind a proxy
    in production environments.
Esempio n. 2
0
def esv_provider():
    return ESVApiTranslationProvider()