Skip to content

Instantly share code, notes, and snippets.

@xy3
Created January 31, 2022 13:51
Show Gist options
  • Select an option

  • Save xy3/47bf1f61af6cc46ab58dcf2da57e8f96 to your computer and use it in GitHub Desktop.

Select an option

Save xy3/47bf1f61af6cc46ab58dcf2da57e8f96 to your computer and use it in GitHub Desktop.
import vweb
import sqlite
struct App {
vweb.Context
pub mut:
db sqlite.DB
}
fn main() {
mut app := App{
db: sqlite.connect(':memory:') or { panic(err) }
}
sql app.db {
create table Movie
}
vweb.run(app, 8081)
}
struct Movie {
id int [primary; sql: serial]
name string
rating f32
tagline string
summary string
description string
hash string
imdbid int
tmdbid int
video_id int
}
['/movie/:id']
fn (mut app App) movie(id int) vweb.Result {
return app.json(sql app.db {
select from Movie where id == id
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment