Exemple #1
0

def is_input_valid(inp_type, val):
    # Uses inp_type instead of is_email for explicitness in function call
    if inp_type == "email":
        return len(val) > 2 and val.count("@") > 0
    return len(val) > 0


# Try to include EE endpoints
try:
    from ee.urls import extend_api_router
except ImportError:
    pass
else:
    extend_api_router(router)


def opt_slash_path(route: str,
                   view: Callable,
                   name: Optional[str] = None) -> str:
    """Catches path with or without trailing slash, taking into account query param and hash."""
    return re_path(route=fr"^{route}/?(?:[?#].*)?$", view=view, name=name)


urlpatterns = [
    # internals
    opt_slash_path("_health", health),
    opt_slash_path("_stats", stats),
    opt_slash_path("_preflight", preflight_check),
    opt_slash_path("_system_status", system_status),
Exemple #2
0

def is_input_valid(inp_type, val):
    # Uses inp_type instead of is_email for explicitness in function call
    if inp_type == "email":
        return len(val) > 2 and val.count("@") > 0
    return len(val) > 0


# Try to include EE endpoints
try:
    from ee.urls import extend_api_router
except ImportError:
    pass
else:
    extend_api_router(router, projects_router=projects_router)


def opt_slash_path(route: str,
                   view: Callable,
                   name: Optional[str] = None) -> URLPattern:
    """Catches path with or without trailing slash, taking into account query param and hash."""
    # Ignoring the type because while name can be optional on re_path, mypy doesn't agree
    return re_path(fr"^{route}/?(?:[?#].*)?$", view, name=name)  # type: ignore


urlpatterns = [
    # internals
    opt_slash_path("_health", health),
    opt_slash_path("_stats", stats),
    opt_slash_path("_preflight", preflight_check),
Exemple #3
0
from posthog.api.decide import hostname_in_app_urls
from posthog.demo import demo
from posthog.models import User

from .utils import render_template
from .views import health, login_required, preflight_check, robots_txt, security_txt, sso_login, stats

ee_urlpatterns: List[Any] = []
try:
    from ee.urls import extend_api_router
    from ee.urls import urlpatterns as ee_urlpatterns
except ImportError:
    pass
else:
    extend_api_router(router,
                      projects_router=projects_router,
                      project_dashboards_router=project_dashboards_router)

try:
    # See https://github.com/PostHog/posthog-cloud/blob/master/multi_tenancy/router.py
    from multi_tenancy.router import extend_api_router as extend_api_router_cloud  # noqa
except ImportError:
    pass
else:
    extend_api_router_cloud(router,
                            organizations_router=organizations_router,
                            projects_router=projects_router)


@csrf.ensure_csrf_cookie
def home(request, *args, **kwargs):