CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-notebook

Jupyter Notebook - A web-based notebook environment for interactive computing

Pending
Overview
Eval results
Files

core-application.mddocs/

Core Application

The core application system provides the main Jupyter Notebook server class and entry points for running the notebook server. This includes configuration management, server lifecycle, and integration with the Jupyter ecosystem.

Capabilities

Main Application Class

The JupyterNotebookApp class is the primary server application that manages the notebook server lifecycle, configuration, and web interface.

class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):
    """
    The notebook server extension app.
    
    This class inherits from LabServerApp and provides notebook-specific
    configuration and functionality while maintaining compatibility with
    the broader Jupyter ecosystem.
    """
    
    # Core application properties
    name: str = "notebook"
    app_name: str = "Jupyter Notebook"
    description: str = "Jupyter Notebook - A web-based notebook environment for interactive computing"
    version: str
    app_version: Unicode  # traitlets Unicode type
    extension_url: str = "/"
    default_url: Unicode = "/tree"  # traitlets Unicode type
    file_url_prefix: str = "/tree"
    load_other_extensions: bool = True
    app_dir: Path
    subcommands: dict[str, Any] = {}
    
    # Configuration options
    expose_app_in_browser: Bool = False  # traitlets Bool type
    custom_css: Bool = True  # traitlets Bool type
    flags: dict
    
    def server_extension_is_enabled(self, extension: str) -> bool:
        """
        Check if a server extension is enabled.
        
        Parameters:
        - extension: str, name of the extension to check
        
        Returns:
        bool: True if extension is enabled, False otherwise
        """
    
    def initialize_handlers(self) -> None:
        """
        Initialize web request handlers.
        
        Sets up URL routing for notebook interface, including tree view,
        notebook editor, console, terminal, and file editor handlers.
        Configures page config and JupyterHub integration if applicable.
        """
    
    def initialize(self, argv: list[str] | None = None) -> None:
        """
        Initialize the notebook application.
        
        Parameters:
        - argv: Optional command line arguments
        
        Subclass method that initializes the extension app without
        taking arguments, unlike the parent class.
        """
    
    @classmethod
    def launch_instance(cls, argv: list[str] | None = None) -> None:
        """
        Launch a new instance of the notebook application.
        
        Parameters:
        - argv: Optional command line arguments
        
        This is the main entry point used by the command line interface
        and programmatic launches of the notebook server.
        """

Application Entry Points

Functions that provide different ways to start the notebook application.

CLI Entry Point Module

The __main__ module provides the command-line interface entry point.

# notebook.__main__ module
# CLI entry point that calls main() and exits with the return code
# Implementation: sys.exit(main())

Main Entry Functions

def main() -> None:
    """
    Main entry point for the notebook application.
    
    This function is used as the console script entry point for
    the 'jupyter-notebook' command. It launches a new instance
    of JupyterNotebookApp using the launch_instance class method.
    
    Equivalent to: JupyterNotebookApp.launch_instance()
    """

def launch_new_instance() -> None:
    """
    Launch a new instance of the notebook application.
    
    Alias for JupyterNotebookApp.launch_instance(), provided for
    compatibility and convenience.
    """

Version Information

Access to package version information in both string and structured formats.

__version__: str
    """
    Package version string (e.g., "7.4.5").
    
    This is the canonical version identifier for the notebook package,
    sourced from notebook._version.__version__.
    """

version_info: VersionInfo
    """
    Structured version information as a named tuple.
    
    Fields:
    - major: int, major version number
    - minor: int, minor version number  
    - micro: int, micro version number
    - releaselevel: str, release level ("" for final releases)
    - serial: str, serial number ("" for final releases)
    """

VersionInfo: type
    """
    Named tuple type for version information.
    
    Used to create structured version data with fields:
    major, minor, micro, releaselevel, serial
    """

Configuration and Constants

Application configuration constants and paths used throughout the notebook system.

aliases: dict
    """
    Command-line aliases configuration inherited from jupyter_core.
    
    Provides standard Jupyter command-line argument aliases for
    configuring the notebook application.
    """

HERE: Path
    """
    Path to the notebook module directory.
    
    Used for locating static files, templates, and other resources
    relative to the notebook package installation.
    """

app_dir: Path
    """
    Application directory path for JupyterLab components.
    
    Directory containing application-specific resources, settings,
    schemas, and themes for the frontend components.
    """

version: str
    """
    Application version string used throughout the system.
    
    Consistent version identifier used in web interfaces and
    API responses.
    """

Usage Examples

Basic Programmatic Usage

from notebook.app import JupyterNotebookApp

# Create and configure application
app = JupyterNotebookApp()
app.initialize()

# Access configuration
print(f"Server running on: {app.default_url}")
print(f"Custom CSS enabled: {app.custom_css}")

# Start the server (blocking)
app.start()

Version Information Access

from notebook import __version__, version_info

print(f"Notebook version: {__version__}")
print(f"Version info: {version_info}")
print(f"Major version: {version_info.major}")
print(f"Is development version: {bool(version_info.releaselevel)}")

Extension Status Check

from notebook.app import JupyterNotebookApp

app = JupyterNotebookApp()
app.initialize()

# Check if an extension is enabled
if app.server_extension_is_enabled('nbclassic'):
    print("NBClassic extension is enabled")
else:
    print("NBClassic extension is not enabled")

Install with Tessl CLI

npx tessl i tessl/pypi-notebook

docs

core-application.md

extension-integration.md

frontend-plugins.md

index.md

web-handlers.md

tile.json