Skip to content

Static Files

When serving a directory, files that do not end in .nubo are served as static files.

Terminal window
nubo serve app

Example:

app/
index.nubo
style.css
logo.png

Routes:

FileURLBehavior
index.nubo/Executed by Nubo.
style.css/style.cssServed as a static file.
logo.png/logo.pngServed as a static file.

Only .nubo files are executable.

app/data.json

The file above is served directly.

If no route matches, Nubo tries to serve a built-in static file.

If that also fails, the request becomes a 404 Not Found.

import response from "@server/response"
response.write("<!doctype html>")
response.write(<html>
<head>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<h1>Hello</h1>
</body>
</html>)

Use an external stylesheet for normal CSS. Literal CSS braces inside an HTML literal can be interpreted as Nubo interpolation. If you need inline CSS, keep trusted CSS in a string and insert it explicitly:

let css = "body { color: navy; }"
let style = <style>!{css}</style>
println(style)

The document type is written as a string because it is not an ordinary HTML tag.