Setting up the vweb web server
We will set up the web server in the main.v file by performing the following steps:
- To begin, import the
vwebandsqlitemodules, as shown in the following code:// file: main.v module main import vweb import sqlite
- Next, we will create a struct, named
App, which appears as follows:// file: main.v struct App { vweb.Context mut: db sqlite.DB }The preceding code shows the
Appstruct, which holdsvweb.Contextalong with fields such as theportfield on which our app will be running and a mutabledbfield of thesqlite.DBtype. - Next, we will modify the
mainfunction, which will appear as follows:// file: main.v fn main() { db := sqlite.connect('notes.db') or { panic(err) } db.exec('drop table if exists Notes') ...