From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001
From: Indrajith K L
Date: Sat, 3 Dec 2022 17:00:20 +0530
Subject: Adds most of the tools
---
.../old/examples/vweb/vweb_assets/assets/index.css | 19 ++++++++++
.../examples/vweb/vweb_assets/assets/v-logo.svg | 1 +
.../v/old/examples/vweb/vweb_assets/favicon.ico | Bin 0 -> 15406 bytes
.../v/old/examples/vweb/vweb_assets/index.html | 12 +++++++
.../v/old/examples/vweb/vweb_assets/vweb_assets.v | 40 +++++++++++++++++++++
5 files changed, 72 insertions(+)
create mode 100644 v_windows/v/old/examples/vweb/vweb_assets/assets/index.css
create mode 100644 v_windows/v/old/examples/vweb/vweb_assets/assets/v-logo.svg
create mode 100644 v_windows/v/old/examples/vweb/vweb_assets/favicon.ico
create mode 100644 v_windows/v/old/examples/vweb/vweb_assets/index.html
create mode 100644 v_windows/v/old/examples/vweb/vweb_assets/vweb_assets.v
(limited to 'v_windows/v/old/examples/vweb/vweb_assets')
diff --git a/v_windows/v/old/examples/vweb/vweb_assets/assets/index.css b/v_windows/v/old/examples/vweb/vweb_assets/assets/index.css
new file mode 100644
index 0000000..4ad9eb8
--- /dev/null
+++ b/v_windows/v/old/examples/vweb/vweb_assets/assets/index.css
@@ -0,0 +1,19 @@
+body {
+ font-family: Arial, Helvetica, sans-serif;
+ color: #eee;
+ background-color: #333;
+ background-image: url("v-logo.svg");
+ background-repeat: no-repeat;
+ background-size: 10em;
+ margin: 0;
+ padding-left: 11em;
+}
+
+h1 {
+ color: #6699CC;
+}
+
+img.logo {
+ float: left;
+ width: 10em;
+}
diff --git a/v_windows/v/old/examples/vweb/vweb_assets/assets/v-logo.svg b/v_windows/v/old/examples/vweb/vweb_assets/assets/v-logo.svg
new file mode 100644
index 0000000..9a4ec60
--- /dev/null
+++ b/v_windows/v/old/examples/vweb/vweb_assets/assets/v-logo.svg
@@ -0,0 +1 @@
+
diff --git a/v_windows/v/old/examples/vweb/vweb_assets/favicon.ico b/v_windows/v/old/examples/vweb/vweb_assets/favicon.ico
new file mode 100644
index 0000000..fa834c3
Binary files /dev/null and b/v_windows/v/old/examples/vweb/vweb_assets/favicon.ico differ
diff --git a/v_windows/v/old/examples/vweb/vweb_assets/index.html b/v_windows/v/old/examples/vweb/vweb_assets/index.html
new file mode 100644
index 0000000..6635329
--- /dev/null
+++ b/v_windows/v/old/examples/vweb/vweb_assets/index.html
@@ -0,0 +1,12 @@
+
+
@message
+ + + diff --git a/v_windows/v/old/examples/vweb/vweb_assets/vweb_assets.v b/v_windows/v/old/examples/vweb/vweb_assets/vweb_assets.v new file mode 100644 index 0000000..058f459 --- /dev/null +++ b/v_windows/v/old/examples/vweb/vweb_assets/vweb_assets.v @@ -0,0 +1,40 @@ +module main + +import vweb +// import vweb.assets +import time + +const ( + port = 8081 +) + +struct App { + vweb.Context +} + +fn main() { + mut app := &App{} + app.serve_static('/favicon.ico', 'favicon.ico') + // Automatically make available known static mime types found in given directory. + app.handle_static('assets', true) + vweb.run(app, port) +} + +pub fn (mut app App) index() vweb.Result { + // We can dynamically specify which assets are to be used in template. + // mut am := assets.new_manager() + // am.add_css('assets/index.css') + // css := am.include_css(false) + title := 'VWeb Assets Example' + subtitle := 'VWeb can serve static assets too!' + message := 'It also has an Assets Manager that allows dynamically specifying which CSS and JS files to be used.' + return $vweb.html() +} + +fn (mut app App) text() vweb.Result { + return app.Context.text('Hello, world from vweb!') +} + +fn (mut app App) time() vweb.Result { + return app.Context.text(time.now().format()) +} -- cgit v1.2.3