Initial project import
This commit is contained in:
commit
23f2d29e32
11957 files changed
+1754577
No files matched your search
@@ -0,0 +1,9 @@
|
||||
# Host a static website
|
||||
|
||||
Here is an example on how to use the Veb server's static capabilities,
|
||||
to host a static website from the `dist/` folder. Just run the server,
|
||||
it will be available at http://localhost:8080/ :
|
||||
|
||||
```bash
|
||||
v run server.v
|
||||
```
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Website other page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, another world!</h1>
|
||||
<p>Welcome to this another page of a demo website.</p>
|
||||
<p><a href="/">Click here</a> to go to main page.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Website main page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, world!</h1>
|
||||
<p>Welcome to this demo website.</p>
|
||||
<p><a href="another.html">Click here</a> to go to another page.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
module main
|
||||
|
||||
import veb
|
||||
import os
|
||||
|
||||
pub struct Context {
|
||||
veb.Context
|
||||
}
|
||||
|
||||
pub struct App {
|
||||
veb.StaticHandler
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// make sure that the working folder is the one, containing the executable,
|
||||
// so that 'dist' is a valid relative path from it later:
|
||||
os.chdir(os.dir(os.executable()))!
|
||||
mut app := &App{}
|
||||
app.handle_static('dist', true)!
|
||||
veb.run[App, Context](mut app, 8080)
|
||||
}
|
||||
Reference in new issue
Block a user