or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-application.mdextension-integration.mdfrontend-plugins.mdindex.mdweb-handlers.md

core-application.mddocs/

0

# Core Application

1

2

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.

3

4

## Capabilities

5

6

### Main Application Class

7

8

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

9

10

```python { .api }

11

class JupyterNotebookApp(NotebookConfigShimMixin, LabServerApp):

12

"""

13

The notebook server extension app.

14

15

This class inherits from LabServerApp and provides notebook-specific

16

configuration and functionality while maintaining compatibility with

17

the broader Jupyter ecosystem.

18

"""

19

20

# Core application properties

21

name: str = "notebook"

22

app_name: str = "Jupyter Notebook"

23

description: str = "Jupyter Notebook - A web-based notebook environment for interactive computing"

24

version: str

25

app_version: Unicode # traitlets Unicode type

26

extension_url: str = "/"

27

default_url: Unicode = "/tree" # traitlets Unicode type

28

file_url_prefix: str = "/tree"

29

load_other_extensions: bool = True

30

app_dir: Path

31

subcommands: dict[str, Any] = {}

32

33

# Configuration options

34

expose_app_in_browser: Bool = False # traitlets Bool type

35

custom_css: Bool = True # traitlets Bool type

36

flags: dict

37

38

def server_extension_is_enabled(self, extension: str) -> bool:

39

"""

40

Check if a server extension is enabled.

41

42

Parameters:

43

- extension: str, name of the extension to check

44

45

Returns:

46

bool: True if extension is enabled, False otherwise

47

"""

48

49

def initialize_handlers(self) -> None:

50

"""

51

Initialize web request handlers.

52

53

Sets up URL routing for notebook interface, including tree view,

54

notebook editor, console, terminal, and file editor handlers.

55

Configures page config and JupyterHub integration if applicable.

56

"""

57

58

def initialize(self, argv: list[str] | None = None) -> None:

59

"""

60

Initialize the notebook application.

61

62

Parameters:

63

- argv: Optional command line arguments

64

65

Subclass method that initializes the extension app without

66

taking arguments, unlike the parent class.

67

"""

68

69

@classmethod

70

def launch_instance(cls, argv: list[str] | None = None) -> None:

71

"""

72

Launch a new instance of the notebook application.

73

74

Parameters:

75

- argv: Optional command line arguments

76

77

This is the main entry point used by the command line interface

78

and programmatic launches of the notebook server.

79

"""

80

```

81

82

### Application Entry Points

83

84

Functions that provide different ways to start the notebook application.

85

86

#### CLI Entry Point Module

87

88

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

89

90

```python { .api }

91

# notebook.__main__ module

92

# CLI entry point that calls main() and exits with the return code

93

# Implementation: sys.exit(main())

94

```

95

96

#### Main Entry Functions

97

98

```python { .api }

99

def main() -> None:

100

"""

101

Main entry point for the notebook application.

102

103

This function is used as the console script entry point for

104

the 'jupyter-notebook' command. It launches a new instance

105

of JupyterNotebookApp using the launch_instance class method.

106

107

Equivalent to: JupyterNotebookApp.launch_instance()

108

"""

109

110

def launch_new_instance() -> None:

111

"""

112

Launch a new instance of the notebook application.

113

114

Alias for JupyterNotebookApp.launch_instance(), provided for

115

compatibility and convenience.

116

"""

117

```

118

119

### Version Information

120

121

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

122

123

```python { .api }

124

__version__: str

125

"""

126

Package version string (e.g., "7.4.5").

127

128

This is the canonical version identifier for the notebook package,

129

sourced from notebook._version.__version__.

130

"""

131

132

version_info: VersionInfo

133

"""

134

Structured version information as a named tuple.

135

136

Fields:

137

- major: int, major version number

138

- minor: int, minor version number

139

- micro: int, micro version number

140

- releaselevel: str, release level ("" for final releases)

141

- serial: str, serial number ("" for final releases)

142

"""

143

144

VersionInfo: type

145

"""

146

Named tuple type for version information.

147

148

Used to create structured version data with fields:

149

major, minor, micro, releaselevel, serial

150

"""

151

```

152

153

### Configuration and Constants

154

155

Application configuration constants and paths used throughout the notebook system.

156

157

```python { .api }

158

aliases: dict

159

"""

160

Command-line aliases configuration inherited from jupyter_core.

161

162

Provides standard Jupyter command-line argument aliases for

163

configuring the notebook application.

164

"""

165

166

HERE: Path

167

"""

168

Path to the notebook module directory.

169

170

Used for locating static files, templates, and other resources

171

relative to the notebook package installation.

172

"""

173

174

app_dir: Path

175

"""

176

Application directory path for JupyterLab components.

177

178

Directory containing application-specific resources, settings,

179

schemas, and themes for the frontend components.

180

"""

181

182

version: str

183

"""

184

Application version string used throughout the system.

185

186

Consistent version identifier used in web interfaces and

187

API responses.

188

"""

189

```

190

191

## Usage Examples

192

193

### Basic Programmatic Usage

194

195

```python

196

from notebook.app import JupyterNotebookApp

197

198

# Create and configure application

199

app = JupyterNotebookApp()

200

app.initialize()

201

202

# Access configuration

203

print(f"Server running on: {app.default_url}")

204

print(f"Custom CSS enabled: {app.custom_css}")

205

206

# Start the server (blocking)

207

app.start()

208

```

209

210

### Version Information Access

211

212

```python

213

from notebook import __version__, version_info

214

215

print(f"Notebook version: {__version__}")

216

print(f"Version info: {version_info}")

217

print(f"Major version: {version_info.major}")

218

print(f"Is development version: {bool(version_info.releaselevel)}")

219

```

220

221

### Extension Status Check

222

223

```python

224

from notebook.app import JupyterNotebookApp

225

226

app = JupyterNotebookApp()

227

app.initialize()

228

229

# Check if an extension is enabled

230

if app.server_extension_is_enabled('nbclassic'):

231

print("NBClassic extension is enabled")

232

else:

233

print("NBClassic extension is not enabled")

234

```