# Generated by gramex init {{ version }} (don't delete this line)
# on {{ date }} by {{ author }} <{{ email }}>

# Configurations for app: {{ appname }}
# ----------------------------------------------------------------------------
url:
  {{ appname }}-home:
    pattern: /$YAMLURL/
    handler: FileHandler
    kwargs:
      path: $YAMLPATH/index.html
      # See https://learn.gramener.com/guide/auth/#authorization for auth rules
      auth: true
      template: true
      headers:
        # Templates may have user-specific content. Cache privately.
        # Keep max-age small (in case we log out & log in as another user.)
        Cache-Control: private, max-age=1
    cache: {expiry: {duration: 1}}

  {{ appname }}-login:
    # Default login_url is /login/. If you change this, change auth.login_url
    # https://learn.gramener.com/guide/auth/#login-urls
    pattern: /$YAMLURL/login/
    # You MUST change the auth before deploying. DBAuth is commonly used.
    # See https://learn.gramener.com/guide/auth/#database-auth
    handler: SimpleAuth
    kwargs:
      template: $YAMLPATH/login.html
      credentials:
        alpha: alpha
        beta: beta

  {{ appname }}-logout:
    pattern: /$YAMLURL/logout/
    handler: LogoutHandler





# Gramex init configurations for app: {{ appname }}
# ----------------------------------------------------------------------------
import:
  # To secure application for production,
  # replace 'YOUR-PROD-SERVER-NAME' with your production server host name.
  deploy if socket.gethostname() in {'YOUR-PROD-SERVER-NAME'}: $GRAMEXPATH/deploy.yaml
  # For alternate methods, see https://learn.gramener.com/guide/config/#conditions

  # /ui/ has Gramex UI components -- use this like the node_modules/ directory
  ui:
    path: $GRAMEXAPPS/ui/gramex.yaml
    YAMLURL: $YAMLURL/ui/

  # /admin/ as an admin page to manage users, get system info, etc.
  admin:
    path: $GRAMEXAPPS/admin2/gramex.yaml    # Note the "admin2" instead of "admin"
    YAMLURL: /$YAMLURL/admin/               # URL to show the admin page at
    ADMIN_KWARGS:
      logo: https://gramener.com/uistatic/gramener.png
      home: /$YAMLURL/
      title: Admin
      theme: '?body-bg=white&navbar-dark-color=rgba(255%2C255%2C255%2C.8)&navbar-dark-hover-color=white'
      # authhandler: name-of-DBAuth-handler    -- required for user management
    ADMIN_AUTH:
      membership:
        hd: gramener.com                    # Only @gramener.com Google Auth are admins

handlers:
  BaseHandler:
    # Custom error pages for this application
    error:
      400: {path: $YAMLPATH/error/400.html}     # Bad request: e.g. URL argument missing
      401: {path: $YAMLPATH/error/401.html}     # Unauthorized: User not logged in
      403: {path: $YAMLPATH/error/403.html}     # Forbidden: user does not have access
      404: {path: $YAMLPATH/error/404.html}     # File not found
      500: {path: $YAMLPATH/error/500.html}     # Internal server error
