www_veda2/web/factory.v
2024-10-07 03:51:32 +02:00

40 lines
751 B
V

module web
//import freeflowuniverse.crystallib.osal
import veb
import os
// import json
// import time
// import rand
pub struct Context {
veb.Context
}
pub struct App {
veb.StaticHandler
pub:
adminkey string
}
// Main entry point
pub fn new() &App {
mut app := &App{}
// Start the Veb web server on port 8080
app.static_mime_types['.map'] = 'txt/plain'
app.mount_static_folder_at('${os.dir(@FILE)}/static', '/static') or { panic(err) }
app.mount_static_folder_at('${os.dir(@FILE)}/static', '/assets') or { panic(err) }
return app
}
@[params]
pub struct RunParams {
port int = 8080
}
pub fn (mut app App) run(params RunParams)! {
veb.run_at[App, Context](mut app, veb.RunParams{ host: '0.0.0.0' port: params.port family: .ip })!
}