www_veda2/web/factory.v

40 lines
751 B
Coq
Raw Normal View History

2024-10-07 01:21:48 +00:00
module web
2024-10-07 01:51:32 +00:00
//import freeflowuniverse.crystallib.osal
2024-10-07 01:21:48 +00:00
import veb
import os
2024-10-07 01:51:32 +00:00
// import json
// import time
// import rand
2024-10-07 01:21:48 +00:00
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) }
2024-10-07 01:37:16 +00:00
app.mount_static_folder_at('${os.dir(@FILE)}/static', '/assets') or { panic(err) }
2024-10-07 01:21:48 +00:00
return app
}
@[params]
pub struct RunParams {
port int = 8080
}
2024-10-07 01:51:32 +00:00
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 })!
2024-10-07 01:21:48 +00:00
}