Skip to content

[uncaught oak error]: NotFound - No such file or directory (os error 2) #13

@ralyodio

Description

@ralyodio

is this not correct layout?

$ find . -type f
./views/index.hbs
./views/layouts/main.hbs
./index.ts
import { Application, Router, Status } from 'https://deno.land/x/oak/mod.ts'
import { Handlebars } from 'https://deno.land/x/handlebars/mod.ts'

const port = 8080

const app = new Application()
const router = new Router()
const handle = new Handlebars()

// the routes defined here
router.get('/', async context => {
    const data = {
			title: 'Fools Day',
			date: '01/04/20'
		}
    context.response.body = await handle.renderView('index', data)
})

app.use(router.routes())
app.use(router.allowedMethods())

// static content
app.use(async (context, next) => {
    const root = `${Deno.cwd()}/static`
    try {
        await context.send({ root })
    } catch {
        next()
    }
})

app.addEventListener("listen", ({ port }) => console.log(`listening on port: ${port}`) )

await app.listen({ port })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions