embercli.py 574 B

123456789101112131415161718
  1. from django.conf import settings
  2. from django.utils.six.moves.urllib.parse import urlparse
  3. def is_ember_cli_request(request):
  4. if settings.DEBUG and settings.MISAGO_EMBER_CLI_ORIGIN:
  5. http_origin = request.META.get('HTTP_ORIGIN', '')
  6. return http_origin.startswith(settings.MISAGO_EMBER_CLI_ORIGIN)
  7. else:
  8. return False
  9. def get_embercli_host():
  10. if settings.MISAGO_EMBER_CLI_ORIGIN:
  11. parsed_url = urlparse(settings.MISAGO_EMBER_CLI_ORIGIN)
  12. return '%s:%s' % (parsed_url.hostname, parsed_url.port)
  13. else:
  14. return None