mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tutorials: a temporary autofree fix in the blog example
This commit is contained in:
parent
f26d2f02b7
commit
de73ef665c
@ -33,8 +33,8 @@ pub fn (app &App) index() vweb.Result {
|
|||||||
|
|
||||||
pub fn (mut app App) init_once() {
|
pub fn (mut app App) init_once() {
|
||||||
app.db = sqlite.connect('blog.db') or { panic(err) }
|
app.db = sqlite.connect('blog.db') or { panic(err) }
|
||||||
app.db.exec('create table if not exists article (' + 'id integer primary key, ' + "title text default ''," +
|
app.db.exec('create table if not exists article (' + 'id integer primary key, ' +
|
||||||
"text text default ''" + ');')
|
"title text default ''," + "text text default ''" + ');')
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut app App) init() {
|
pub fn (mut app App) init() {
|
||||||
@ -44,8 +44,7 @@ pub fn (mut app App) new() vweb.Result {
|
|||||||
return $vweb.html()
|
return $vweb.html()
|
||||||
}
|
}
|
||||||
|
|
||||||
[post]
|
['/new_article'; post]
|
||||||
['/new_article']
|
|
||||||
pub fn (mut app App) new_article() vweb.Result {
|
pub fn (mut app App) new_article() vweb.Result {
|
||||||
title := app.form['title']
|
title := app.form['title']
|
||||||
text := app.form['text']
|
text := app.form['text']
|
||||||
@ -66,7 +65,8 @@ pub fn (mut app App) new_article() vweb.Result {
|
|||||||
|
|
||||||
pub fn (mut app App) articles() {
|
pub fn (mut app App) articles() {
|
||||||
articles := app.find_all_articles()
|
articles := app.find_all_articles()
|
||||||
app.json(json.encode(articles))
|
x := json.encode(articles)
|
||||||
|
app.json(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut app App) time() {
|
fn (mut app App) time() {
|
||||||
|
Loading…
Reference in New Issue
Block a user