O Language/Web Framework
From OnixOS
O Language Web Framework (olf)
olf is the convention-based web framework for O Language. It provides a project layout for routes, controllers, templates, browser assets, and database code.
Create and run a project
olang web init my-project cd my-project olang web run
The official framework source is the olf repository.
Project structure
| Path | Responsibility |
|---|---|
boot.ola |
Starts the application by loading lib/loader.olm.
|
lib/loader.olm |
Central loader for every generated and installed module. |
config/config.ola |
HTTP route table. |
controllers/ |
Request handler functions. |
models/ |
Data model definitions. |
connections/ |
Database connection definitions. |
templates/ |
Server-rendered HTML templates. |
public/ |
Browser assets. |
library.olp |
Project metadata and dependencies. |
proc.ops |
Local process definition. |
Generate application components
olang web create controller home olang web create model user olang web create connection main olang web create route get /users/:id show_user
The web CLI updates lib/loader.olm whenever it creates or installs a component. Controller and route definitions are written to config/config.ola; no separate route file is created. Generated controller functions are intentionally empty so the developer can fill in the behavior.
Add libraries
olang web add <remote> <library-name> olang web install olang web update
The dependency is recorded in library.olp, installed under lib/, and its entry point is added to the central loader.
Templates and request data
def main = fn() {
return renderf("templates/index.html", {
"title": "My Olang App",
"body": "Welcome!"
})
}
Use server.parameters for route parameters and server.get, server.post, server.headers, and server.form for request data.
