docs: def publ(name, cfg):
      """ Create a Flask app and configure it for use with Publ """
  
      config.setup(cfg)
  
      app = _PublApp(name,
                     template_folder=config.template_folder,
                     static_folder=config.static_folder,
                     static_url_path=config.static_url_path)
  
      for route in [
              '/',
              '/<path:category>/',
              '/<template>',
              '/<path:category>/<template>',
      ]:
          app.add_url_rule(route, 'category', rendering.render_category)
  
      for route in [
              '/<int:entry_id>',
              '/<int:entry_id>-',
              '/<int:entry_id>-<slug_text>',
              '/<path:category>/<int:entry_id>',
              '/<path:category>/<int:entry_id>-',
              '/<path:category>/<int:entry_id>-<slug_text>',
      ]:
          app.add_url_rule(route, 'entry', rendering.render_entry)
  
      app.add_url_rule('/<path:path>.PUBL_PATHALIAS',
                       'path_alias', rendering.render_path_alias)
  
      app.add_url_rule('/_async/<path:filename>',
                       'async', image.get_async)
  
      app.add_url_rule('/_', 'chit', rendering.render_transparent_chit)
  
      app.add_url_rule('/_file/<path:filename>',
                       'asset', rendering.retrieve_asset)
  
      app.config['TRAP_HTTP_EXCEPTIONS'] = True
      app.register_error_handler(
          werkzeug.exceptions.HTTPException, rendering.render_exception)
  
      app.jinja_env.globals.update(  # pylint: disable=no-member
          get_view=view.get_view,
          arrow=arrow,
          static=utils.static_url,
          get_template=rendering.get_template
      )
  
      caching.init_app(app)
  
      maint = maintenance.Maintenance()
  
      if config.index_rescan_interval:
          maint.register(functools.partial(index.scan_index,
                                           config.content_folder),
                         config.index_rescan_interval)
  
      if config.image_cache_interval and config.image_cache_age:
          maint.register(functools.partial(image.clean_cache,
                                           config.image_cache_age),
                         config.image_cache_interval)
  
      app.before_request(maint.run)
  
      if 'CACHE_THRESHOLD' in config.cache:
          app.after_request(set_cache_expiry)
  
      if app.debug:
          # We're in debug mode so we don't want to scan until everything's up
          # and running
          app.before_first_request(startup)
      else:
          # In production, register the exception handler and scan the index
          # immediately
          app.register_error_handler(Exception, rendering.render_exception)
          startup()
  
      return app