From 6f5fae7d74c4181a6ef2f7b4349be2d63276b046 Mon Sep 17 00:00:00 2001 From: libexi01 Date: Mon, 1 Jul 2024 02:43:38 +0530 Subject: [PATCH] 29 --- src/main.v | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main.v diff --git a/src/main.v b/src/main.v new file mode 100644 index 0000000..b1eada4 --- /dev/null +++ b/src/main.v @@ -0,0 +1,45 @@ +module main + +import vweb +import os +import databases + +const ( + port = 8082 +) + +struct App { + vweb.Context +} + +pub fn (app App) before_request() { + println('[web] before_request: ${app.req.method} ${app.req.url}') +} + +fn main() { + mut db := databases.create_db_connection() or { panic(err) } + + sql db { + // create table Faculty ( + // id serial primary key, + // name text not null, + // email text not null unique, + // password text not null + // ) + create table Auth + } or { panic('error on create table: ${err}') } + + db.close() or { panic(err) } + + mut app := &App{} + app.serve_static('/favicon.ico', 'src/assets/favicon.ico') + // makes all static files available. + app.mount_static_folder_at(os.resource_abs_path('.'), '/') + + vweb.run(app, port) +} + +pub fn (mut app App) login() vweb.Result { + + return $vweb.html() +}