O Language

O Language web projects

The olang web command group, generated project layout and route configuration.

O Language pagesFramework project guide
On this page

The olang web command group manages a project rooted in the current working directory. The framework and its generated files are separate from the core interpreter.

Initialize a project

olang web init my-site

With no remote argument, the command clones the default framework repository and scaffolds the project under my-site. To select another framework source:

olang web init https://example.org/framework.git my-site

The scaffold includes a boot.ola, proc.ops, library.olp, a loader, a controller and a route configuration. The default boot file loads its library and starts the web server:

load "lib/loader.olm"

webserver("10000", config)

Route configuration

Routes are stored as a hash keyed by path. Each entry supplies a method and response:

def config = {
    "/": {"type": "GET", "response": main}
}

The web server accepts a port and a route configuration:

webserver("10000", config)

A response may be a string or a function. The server also reads route options for headers, uploads, static folders and status codes; inspect evaluator/server.go before relying on advanced options.

Create and manage project files

Command Effect
olang web create controller NAME Creates a controller file and adds a GET route to the config.
olang web create model NAME Creates a model template, a default SQLite connection when needed, and loader entries.
olang web create connection NAME Creates a SQLite connection template and a loader entry.
olang web create route METHOD PATH CONTROLLER Adds a route entry to config/config.ola. The methods accepted by this command are GET, POST, PUT, DELETE and PATCH; update is normalized to PUT.
olang web add URL NAME Adds and synchronizes a library dependency.
olang web install, olang web update Synchronizes libraries listed in the project manifest.
olang web run, olang web stop Starts or stops the project’s proc.ops entries.
olang web artifact FILE Writes a ZIP of the project tree, skipping .git directories. The extension is added when omitted.

Each web command accepts –debug or -d.

Current scaffold limitation

The controller, model and connection generators currently write # comment lines into generated source files. The lexer treats # as end-of-input, so remove those generated comment lines before running the affected file. This is an implementation mismatch in the current source; it is not valid language comment syntax.

The scaffold and server operate on local files, start processes and can bind a network port. Review generated commands and route/upload settings before using them outside a development machine.