76 lines
1.6 KiB
V
76 lines
1.6 KiB
V
module main
|
|
|
|
import veb
|
|
import os
|
|
|
|
pub struct App {
|
|
veb.Controller
|
|
}
|
|
|
|
pub struct Index {}
|
|
|
|
pub struct Context {
|
|
veb.Context
|
|
}
|
|
|
|
@['/fr']
|
|
pub fn (app &Index) fr(mut ctx Context) veb.Result {
|
|
info := os.execute("v doctor")
|
|
file := os.read_file("main.v") or {panic(err)}
|
|
return ctx.text("v doctor:\n ${info}\n main.v: \n${file}")
|
|
}
|
|
|
|
// we do a little crutches
|
|
@['/']
|
|
pub fn (app &Index) index(mut ctx Context) veb.Result {
|
|
return ctx.file("static/index.html")
|
|
}
|
|
|
|
@['/index.css']
|
|
pub fn (app &Index) css(mut ctx Context) veb.Result {
|
|
return ctx.file("static/index.css")
|
|
}
|
|
|
|
@['/index.js']
|
|
pub fn (app &Index) js(mut ctx Context) veb.Result {
|
|
script := os.read_file("static/index.js") or {panic(err)}
|
|
return ctx.text(script)
|
|
}
|
|
|
|
@['/v-logo.png']
|
|
pub fn (app &Index) logo(mut ctx Context) veb.Result {
|
|
return ctx.file("static/v-logo.png")
|
|
}
|
|
|
|
@['/throne.webp']
|
|
pub fn (app &Index) throne(mut ctx Context) veb.Result {
|
|
return ctx.file("static/throne.webp")
|
|
}
|
|
|
|
@['/soon.webp']
|
|
pub fn (app &Index) soon(mut ctx Context) veb.Result {
|
|
return ctx.file("static/soon.webp")
|
|
}
|
|
|
|
@['/em_soon.webp']
|
|
pub fn (app &Index) em_soon(mut ctx Context) veb.Result {
|
|
return ctx.file("static/em_soon.webp")
|
|
}
|
|
|
|
@['/em_wip.webp']
|
|
pub fn (app &Index) em_wip(mut ctx Context) veb.Result {
|
|
return ctx.file("static/em_wip.webp")
|
|
}
|
|
|
|
@['/stealer.webp']
|
|
pub fn (app &Index) stealer(mut ctx Context) veb.Result {
|
|
return ctx.file("static/stealer.webp")
|
|
}
|
|
fn main() {
|
|
mut app := &App{}
|
|
|
|
mut index_app := &Index{}
|
|
app.register_controller[Index, Context]("/", mut index_app)!
|
|
|
|
veb.run[App, Context](mut app, 5252)
|
|
}
|