Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

@@ -0,0 +1,44 @@
module main
import veb
const port = 8082
pub struct Context {
veb.Context
}
pub struct App {
}
fn main() {
mut app := &App{}
veb.run[App, Context](mut app, port)
}
pub fn (mut app App) index() veb.Result {
return $veb.html()
}
@['/upload'; post]
pub fn (mut app App) upload(mut ctx Context) veb.Result {
fdata := ctx.files['upfile']
data_rows := fdata[0].data.split('\n')
mut output_data := ''
for elem in data_rows {
delim_row := elem.split('\t')
output_data += '${delim_row[0]}\t${delim_row[1]}\t${delim_row[0].int() + delim_row[1].int()}\n'
}
output_data = output_data.all_before_last('\n')
println(output_data)
ctx.set_header(.content_disposition, 'attachment; filename=results.txt')
ctx.send_response_to_client('application/octet-stream', output_data)
return $veb.html()
}
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test file uploading data transformation</title>
</head>
<body>
<h2>File Upload and Data Transformation</h2>
Upload the <b>sample_input.txt</b> located in this example folder.
<br>
<br>
V will apply data transformation, adding the first two columns into a third column, and return the results as a download. <br>
<br>
For example:
<table style="color:blue;">
<tr>
<td>10</td>
<td>13</td>
</tr>
<tr>
<td>20</td>
<td>54</td>
</tr>
<tr>
<td>30</td>
<td>82</td>
</tr>
<tr>
<td>40</td>
<td>11</td>
</tr>
<tr>
<td>50</td>
<td>47</td>
</tr>
</table>
<br>
Becomes...
<br>
<table style="color:blue;">
<tr>
<td>10</td>
<td>13</td>
<td>23</td>
</tr>
<tr>
<td>20</td>
<td>54</td>
<td>74</td>
</tr>
<tr>
<td>30</td>
<td>82</td>
<td>112</td>
</tr>
<tr>
<td>40</td>
<td>11</td>
<td>51</td>
</tr>
<tr>
<td>50</td>
<td>47</td>
<td>97</td>
</tr>
</table>
<hr>
File form:
<form method="POST" enctype="multipart/form-data" action="http://localhost:8082/upload">
<input type="file" name="upfile"/>
<input type="submit" value="Upload & Transform"/>
</form>
</body>
</html>
@@ -0,0 +1,5 @@
10 13
20 54
30 82
40 11
50 47
@@ -0,0 +1,2 @@
<meta charset="utf-8">
<a href="/">Back</a>