aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/examples/vweb/file_upload/vweb_example.v
blob: bde55c321b78ca9206c555b0b6e391ce2e52e8aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module main

import vweb

const (
	port = 8082
)

struct App {
	vweb.Context
}

fn main() {
	vweb.run(&App{}, port)
}

pub fn (mut app App) index() vweb.Result {
	return $vweb.html()
}

['/upload'; post]
pub fn (mut app App) upload() vweb.Result {
	fdata := app.files['upfile']

	mut files := []vweb.RawHtml{}

	for d in fdata {
		files << d.data.replace_each(['\n', '<br>', '\n\r', '<br>', '\t', '	', ' ', '&nbsp;'])
	}

	return $vweb.html()
}