2021-01-21 11:08:51 +01:00
|
|
|
module main
|
|
|
|
|
|
|
|
import vweb
|
|
|
|
|
2021-11-10 17:26:16 +01:00
|
|
|
const port = 8082
|
2021-01-21 11:08:51 +01:00
|
|
|
|
|
|
|
struct App {
|
|
|
|
vweb.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2021-05-11 10:10:35 +02:00
|
|
|
vweb.run(&App{}, port)
|
2021-01-21 11:08:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (mut app App) index() vweb.Result {
|
|
|
|
return $vweb.html()
|
|
|
|
}
|
|
|
|
|
2021-04-20 16:16:35 +02:00
|
|
|
['/upload'; post]
|
2021-01-21 11:08:51 +01:00
|
|
|
pub fn (mut app App) upload() vweb.Result {
|
2021-11-10 17:26:16 +01:00
|
|
|
dump(app.form)
|
|
|
|
dump(app.files)
|
2021-01-21 11:08:51 +01:00
|
|
|
fdata := app.files['upfile']
|
|
|
|
mut files := []vweb.RawHtml{}
|
|
|
|
for d in fdata {
|
2021-04-20 16:16:35 +02:00
|
|
|
files << d.data.replace_each(['\n', '<br>', '\n\r', '<br>', '\t', ' ', ' ', ' '])
|
2021-01-21 11:08:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $vweb.html()
|
|
|
|
}
|
2021-11-10 17:26:16 +01:00
|
|
|
|
|
|
|
['/submit'; post]
|
|
|
|
pub fn (mut app App) submit() vweb.Result {
|
|
|
|
dump(app.form)
|
|
|
|
form_data := app.form.clone()
|
|
|
|
return $vweb.html()
|
|
|
|
}
|