40 lines
592 B
V
40 lines
592 B
V
module main
|
|
|
|
import veb
|
|
import db.sqlite
|
|
import veb.auth
|
|
|
|
pub struct App {
|
|
veb.StaticHandler
|
|
pub mut:
|
|
db sqlite.DB
|
|
auth auth.Auth[sqlite.DB]
|
|
}
|
|
|
|
pub struct Context {
|
|
veb.Context
|
|
user User
|
|
}
|
|
|
|
pub fn (app &App) index(mut ctx Context) veb.Result {
|
|
return ctx.text('Namaste India!!!')
|
|
}
|
|
|
|
fn main() {
|
|
mut app := &App{
|
|
db: sqlite.connect('app.db')!
|
|
}
|
|
|
|
sql app.db {
|
|
create table User
|
|
create table Plane
|
|
create table Ticket
|
|
} or { panic('error on create table: ${err}') }
|
|
|
|
app.auth = auth.new(app.db)
|
|
|
|
app.handle_static('static', false)!
|
|
|
|
veb.run[App, Context](mut app, 8080)
|
|
}
|