examples: fix static vweb assets example (#11008)

pull/11017/head
shadow 2021-08-01 14:46:30 -04:00 committed by GitHub
parent dbf5c976a3
commit eca7af107a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<html> <html>
<header> <header>
<title>@title</title> <title>@title</title>
@css 'examples/vweb/vweb_assets/assets/index.css' @css 'index.css'
</header> </header>
<body> <body>
<h1>@title</h1> <h1>@title</h1>

View File

@ -13,17 +13,11 @@ struct App {
} }
fn main() { fn main() {
vweb.run(&App{}, port) mut app := &App{}
}
pub fn (mut app App) init_server() {
// Arbitary mime type.
app.serve_static('/favicon.ico', 'favicon.ico') app.serve_static('/favicon.ico', 'favicon.ico')
// Automatically make available known static mime types found in given directory. // Automatically make available known static mime types found in given directory.
// app.handle_static('assets') app.handle_static('assets', true)
// This would make available all known static mime types from current vweb.run(app, port)
// directory and below.
app.handle_static('.', false)
} }
pub fn (mut app App) index() vweb.Result { pub fn (mut app App) index() vweb.Result {