| 1 | module main |
| 2 | |
| 3 | import veb |
| 4 | import os |
| 5 | |
| 6 | pub struct Context { |
| 7 | veb.Context |
| 8 | } |
| 9 | |
| 10 | struct App { |
| 11 | veb.StaticHandler |
| 12 | } |
| 13 | |
| 14 | fn main() { |
| 15 | os.chdir(os.dir(@FILE))! |
| 16 | cmd := '${os.quoted_path(@VEXE)} -b wasm -os browser mandelbrot.wasm.v' |
| 17 | println('>> compiling mandelbrot.wasm.v, using: ${cmd}') |
| 18 | os.execute_or_panic(cmd) |
| 19 | mut app := &App{} |
| 20 | app.handle_static('.', true)! |
| 21 | veb.run[App, Context](mut app, 3001) |
| 22 | } |
| 23 | |
| 24 | pub fn (mut app App) index(mut ctx Context) veb.Result { |
| 25 | return ctx.html(os.read_file('mandelbrot.html') or { '' }) |
| 26 | } |
| 27 | |