Skip to content

Commit 1aec40a

Browse files
committed
vweb: flush stdout after the Running app on message, fix potential invalid map value access in serve_if_static
1 parent 65a020e commit 1aec40a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

vlib/vweb/vweb.v

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ pub fn run_at[T](global_app &T, params RunParams) ! {
415415
}
416416
host := if params.host == '' { 'localhost' } else { params.host }
417417
println('[Vweb] Running app on http://${host}:${params.port}/')
418+
flush_stdout()
418419
for {
419420
// Create a new app object for each connection, copy global data like db connections
420421
mut request_app := &T{}
@@ -607,8 +608,8 @@ fn route_matches(url_words []string, route_words []string) ?[]string {
607608
[manualfree]
608609
fn serve_if_static[T](mut app T, url urllib.URL) bool {
609610
// TODO: handle url parameters properly - for now, ignore them
610-
static_file := app.static_files[url.path]
611-
mime_type := app.static_mime_types[url.path]
611+
static_file := app.static_files[url.path] or { return false }
612+
mime_type := app.static_mime_types[url.path] or { return false }
612613
if static_file == '' || mime_type == '' {
613614
return false
614615
}
@@ -706,7 +707,7 @@ pub fn (ctx &Context) ip() string {
706707

707708
// Set s to the form error
708709
pub fn (mut ctx Context) error(s string) {
709-
println('vweb error: ${s}')
710+
eprintln('vweb error: ${s}')
710711
ctx.form_error = s
711712
}
712713

0 commit comments

Comments
 (0)