All Projects β†’ mufeedvh β†’ Binserve

mufeedvh / Binserve

Licence: mit
A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. βš‘οΈπŸ¦€

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Binserve

Cppwebframework
​The C++ Web Framework (CWF) is a MVC web framework, Open Source, under MIT License, using C++ with Qt to be used in the development of web applications.
Stars: ✭ 348 (-13.22%)
Mutual labels:  server, http-server, webserver
Hummingbird
Lightweight, flexible HTTP server framework written in Swift
Stars: ✭ 114 (-71.57%)
Mutual labels:  server, http-server, web-server
Iodine
iodine - HTTP / WebSockets Server for Ruby with Pub/Sub support
Stars: ✭ 720 (+79.55%)
Mutual labels:  server, http-server, webserver
Rayo.js
Micro framework for Node.js
Stars: ✭ 170 (-57.61%)
Mutual labels:  server, http-server, webserver
Fenix
A simple and visual static web server with collaboration features.
Stars: ✭ 1,559 (+288.78%)
Mutual labels:  static-site, http-server, web-server
Nodemcu Espress
Ultra-Lightweight and modular Node.js express like http server for NodeMCU. web - ESP8266
Stars: ✭ 39 (-90.27%)
Mutual labels:  static, server, http-server
Pure Http
✨ The simple web framework for Node.js with zero dependencies.
Stars: ✭ 139 (-65.34%)
Mutual labels:  server, http-server, webserver
Kvantum
An intellectual (HTTP/HTTPS) web server with support for server side templating (Crush, Apache Velocity and JTwig)
Stars: ✭ 17 (-95.76%)
Mutual labels:  web-server, webserver, http-server
stirfry
StirFry is a self contained and lightweight web framework for nodejs
Stars: ✭ 24 (-94.01%)
Mutual labels:  web-server, webserver, http-server
httoop
HTTOOP - a fully object oriented HTTP protocol library written in python
Stars: ✭ 15 (-96.26%)
Mutual labels:  webserver, http-server
eventually-jekyll-theme
A Jekyll version of the "Eventually" theme by HTML5 UP.
Stars: ✭ 26 (-93.52%)
Mutual labels:  static, static-site
Http
Host These Things Please - a basic http server for hosting a folder fast and simply
Stars: ✭ 275 (-31.42%)
Mutual labels:  server, http-server
Nodemcu Httpserver
A (very) simple web server written in Lua for the ESP8266 firmware NodeMCU.
Stars: ✭ 369 (-7.98%)
Mutual labels:  http-server, webserver
crab
πŸ¦€ a simple web server
Stars: ✭ 18 (-95.51%)
Mutual labels:  web-server, http-server
Pegasus.lua
πŸš€ Pegasus.lua is an http server to work with web applications written in Lua language.
Stars: ✭ 274 (-31.67%)
Mutual labels:  server, http-server
EthernetWebServer
This is simple yet complete WebServer library for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21/SAMD51, nRF52, STM32, RP2040-based, etc. boards running Ethernet shields. The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32. Coexisting now with `ESP32 WebServer` and…
Stars: ✭ 118 (-70.57%)
Mutual labels:  webserver, http-server
Webserver
A C++ High Performance Web Server
Stars: ✭ 4,164 (+938.4%)
Mutual labels:  http-server, webserver
Statik
Embed files into a Go executable
Stars: ✭ 3,348 (+734.91%)
Mutual labels:  static, http-server
stacy
Website generator that combines content from Contentful CMS with Handlebars templates and publishes the website in Amazon S3.
Stars: ✭ 24 (-94.01%)
Mutual labels:  handlebars, static-site
Beast
HTTP and WebSocket built on Boost.Asio in C++11
Stars: ✭ 3,241 (+708.23%)
Mutual labels:  server, http-server

binserve βš‘οΈπŸ¦€

A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. πŸ”₯

UPDATE: Next version will be releasing soon with Automatic TLS (HTTPS), More speed, SEO features, and much more! πŸŽ‰

version GitHub license Twitter

Table of Contents


Features

  • Single binary with no dependencies and everything built-in.
  • Blazingly fast! ⚑️ - it's built on top of Actix, one of the fastest web frameworks in the world and of course, written in Rust.
  • Everything in a single config file - everything you need to setup is in the binserve.json, just change it, run it!
  • Epic Portability - just carry the binary around and all you have to change is the host and port in the binserve.json.
  • Easiest Routing - you just have to enter the route and the static file to respond in the binserve.json to add a route entry!
  • Handlebars template engine - renders every static file with Handlebars on the first run improving performance!
  • Template Variables in one place - that too in the one and only config file!
  • Secure by design - runs security validation checks on the first run and will only run the server once configuration is confirmed secure! (See Security)
  • Config & Static File Assistance - just running it will create the configuration file and the static directory boilerplate for you!
  • Supports Any Static Files - just give any static file of your choice to routes and response will match it's Content-Type.
  • Straightforward Directory Structure - static files falls under the static directory, you can even change that! And images, css, and js falls under the assets directory which should all be created for you in the first run itself!
  • Custom Error Page Support - you can design your own fancy error pages!
  • Actix Logging Middleware - Logging is powered directly from Actix.

Hello World!

Download the binary for your OS from Releases, then just run it:

$ binserve

That's it. Done! You should see the following output:

         _   _                         
        | |_|_|___ ___ ___ ___ _ _ ___ 
        | . | |   |_ -| -_|  _| | | -_|
        |___|_|_|_|___|___|_|  \_/|___| v0.1.0
    

Your server is up and running at http://example.com:80/

Here is how the directory structure will look like:

β”œβ”€β”€ binserve
β”œβ”€β”€ binserve.json
β”œβ”€β”€ rendered_templates
β”‚   β”œβ”€β”€ 404.html
β”‚   └── index.html
└── static
    β”œβ”€β”€ 404.html
    β”œβ”€β”€ assets
    β”‚   β”œβ”€β”€ css
    β”‚   β”œβ”€β”€ images
    β”‚   └── js
    └── index.html

βš™οΈ Configuration File:

πŸ“„ File: binserve.json

{
  "directory_listing": false,
  "enable_logging": true,
  "error_pages": {
    "404": "404.html"
  },
  "follow_symlinks": false,
  "routes": {
    "/": "index.html",
    "/example": "example.html"
  },
  "server": {
    "host": "127.0.0.1",
    "port": 1337
  },
  "static_directory": "static",
  "template_variables": {
    "load_static": "/static/",
    "name": "Binserve"
  }
}

The whole thing revolves around this configuration file, whatever changes you want to make, just edit the config and run it!

🎨 Templates:

binserve uses Handlebars as the template engine as it perfectly fits our use case.

Here is an example:

<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <h1>My name is {{name}}</h1>
    </body>
</html>

Now add your name in the config file (binserve.json) as a template variable:

"template_variables": {
    "load_static": "/static/",
    "name": "Keanu Reeves"
}

Now run the server!

$ binserve

This would render down to:

<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <h1>My name is Keanu Reeves</h1>
    </body>
</html>

To load static files such as images, css, and javascript, just use {{load_static}}:

load_static is specified in the binserve.json itself.

<img src="{{load_static}}images/rick_roll.gif">
<link rel="stylesheet" href="{{load_static}}css/main.css">
<script src="{{load_static}}js/script.js">

binserve renders all your template at once on the first run itself to improve performance as it wouldn't have to render the template on each request.

Build From Source

For building binserve from source, you need to have these tools installed

  • Git
  • Rust
  • Cargo (Automatically installed when installing Rust)
  • A C linker (Only for Linux, generally comes pre-installed)
$ git clone https://github.com/mufeedvh/binserve.git
$ cd binserve/
$ cargo build --release

The first command clones the binserve repository in your local machine. The next two commands changes into the binserve directory and builds it in release mode

Security

Security is one of the most crucial elements in a web server, binserve is secure by design. Here is how it's secure:

  • Routes are specified in the configuration file not directly accepted from the user.
  • Runs a check for Path Traversal attempts in routes in the configuration file on each run.
  • Runs a check for Symlink Files which might point to sensitive files on each run.
  • Only Follows Symlinks when explicitly allowed in the configuration file which is disabled by default.
  • Only enables Directory Listing when explicitly allowed in the configuration file which is disabled by default.

Contribution

Ways to contribute

  • Suggest a feature
  • Report a bug
  • Fix something and open a pull request
  • Help me document the code
  • Spread the word
  • Create an example with binserve and you will be featured here!

License

Licensed under the MIT License, see LICENSE for more information.

Liked the project?

Support the author by buying him a coffee!

Buy Me A Coffee


Support this project by starring ⭐, sharing πŸ“², and contributing πŸ‘©β€πŸ’»! ❀️


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].