Git Product home page Git Product logo

bash-web-server's Introduction

Bash-web-server

A purely bash web server, no socat, netcat, etc...

Requirement

  • bash 5.2 (The patch will be included in bash5.2 - Alpha release already contains the patch)
  • if bash version is under 5.2, patched loadable accept builtin (http://git.savannah.gnu.org/cgit/bash.git/tree/examples/loadables/accept.c) is needed, you have to apply accept.patch to your loadable accept.c file which is existed in bash source code, and than build and install the loadable accept builtin into BASH_LOADABLE_PATH specified in bash-server.sh

How to

The port can be set by the env var: HTTP_PORT

The path to accept (Directory) can be set by using: BASH_LOADABLES_PATH (see man bash)

Server Methods:

  • serveHtml (needs DOCUMENT_ROOT envvars) - This will serve the static files
  • script file - The script need a file as first argument which will be source. The file will need a function named runner, which will be run on each request

Basic authentication can be enabled by env var: BASIC_AUTH, accounts and passwords are stored in the file specified in $BASIC_AUTH_FILE

Usage

Simple explication of various functions that could be used.

Session Handling

Variables:

    SESSION_COOKIE
        The name of the cookie : default BASHSESSID

Functions:

    sessionStart
        Start a session or reuse an existing session

    sessionSet $1 $2
        Set a session variable

    sessionGet $1 
        Get the value of the given variable

Cookie Handling

Functions:

    cookieSet $1 
        Send the cookie
        Example: cookieSet "BASHSESSID=12345; max-age=5000" 

HTTP Handling

Functions:

    httpSendStatus $1 
        Send the provided http status
        Example: httpSendStatus 200

    To set Headers, you should add an entry inside the assoc var HTTP_RESPONSE_HEADERS
        HTTP_RESPONSE_HEADERS["ExampleHeader"]="The value of the Header"

Websocket

!!!NOTE: This is still expiremental and only works for sendin data, not receiving!

Functions:

    websocketStart FUNCTION
        Start the websocket server

    websocketStop
        Stop the websocket server inside the function

bash-web-server's People

Contributors

andersjanmyr avatar cheese1 avatar dzove855 avatar gothicx avatar iaguozhi avatar ymzkei5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bash-web-server's Issues

Accept requests in lan

Currently the web server can only be accessed in the same machine, I want to support accessing from lan without netcat and other tools. Any ideas about it?

"Cannot load accept" despite bash 5.2.0(1)-alpha

I tried to make it work on the 5.2.0(1)-alpha version of bash

  • i have the "cannot load accept" error

I tried with bash 5.0

  • Applying the patch said it has some rejection, it is normal?
  • Compiling the patched accept.c isn't smooth at all i have no clue how to do it.
  • Also even if i had it to compile what i am supposed to do with the binary in the end?

Any idea? thanks.

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.