Coder Social home page Coder Social logo

smartiniongithub / vweb-example Goto Github PK

View Code? Open in Web Editor NEW
9.0 5.0 1.0 287 KB

Example webapp with vweb, made in V

License: Apache License 2.0

V 28.89% CSS 22.80% HTML 8.13% Makefile 27.36% AMPL 1.38% Dockerfile 11.44%
vweb example test webapp vlang docker hacktoberfest

vweb-example's Introduction

vweb-example

Apache 2.0 License

Example webapp with vweb (V integrated web framework).

Setup and run

Ensure V is updated (maybe force an update with v up) and in PATH.

A make file (cmake) has been added to simplify shell commands execution and related dependencies, just for convenience; to run it with a default (informative only) task, do:

make

all commands inside are for the Bash shell (so for Linux and similar systems).

Note that required resources are bundled inside the executable, or will be copied (by additional shell commands in build phase) in the same folder of the executable, to ensure to have all consistent there.

Inside this project there are other (utility) sources, moved in its own folder:

  • './healthcheck/' contains a command-line utility that calls the given HTTP endpoint to check its health status, useful for example when main server application is running in a container
  • './minimal/' contains a (very) minimal web application that only exposes a fixed message on its root route
  • others later ...

Note that there are many Dockerfiles (and related make tasks), to use different base images; see details in the 'Makefile'. To build sources in containers, it's recommended to use official vlang Docker images, otherwise dependencies must be added manually. When executables are built with static dependencies (all inside it), it's even possible to run them in a special Docker image ('scratch') empty, so really minimal and safer (no shell inside and nothing other than my executables and related resources).

In the docs folder there is other documentation.

Requirements

Latest V (vlang) stable, or built from latest sources.

To run the application in a container, an updated version of Docker is needed.

Note

Current setup (and related commands) are for a Linux system, but can be updated for other platforms (Mac, Windows, etc).

Executable files generated from V code are very small, and by default all published web resources are bundled inside executables to simplify deploy.

Just to have an idea, the minimal web server script ('server-minimal.v' -> 'vweb-minimal') when built on a modern Linux distribution (like Ubuntu 20.04 LTS at 64 bit) is:

  • normal build: from 140 KB to 240 KB
  • normal build optimized (for production and compressed): from 70 KB to 100 KB
  • static build (no external libraries): approx. 4.5 MB
  • static build optimized (no external libraries): approx. 1.8 MB

all this is impressive.

When building the same sources in Windows, executables are bigger (double than Linux, approx.), but anyway very small.

License

Licensed under Apache-2.0.


vweb-example's People

Contributors

smartiniongithub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

govlang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.