41 lines
		
	
	
		
			830 B
		
	
	
	
		
			V
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			830 B
		
	
	
	
		
			V
		
	
	
	
	
	
| module web
 | |
| import x.templating.dtm
 | |
| //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 mut:
 | |
| 	adminkey string
 | |
| 	dtm &dtm.DynamicTemplateManager = dtm.initialize()
 | |
| }
 | |
| 
 | |
| // 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 })!
 | |
| }
 |