An open API service indexing awesome lists of open source software.

https://github.com/alexgustafsson/bashd

A PoC CGI-styled web server and framework written in Bash
https://github.com/alexgustafsson/bashd

cgi proof-of-concept webserver

Last synced: about 1 month ago
JSON representation

A PoC CGI-styled web server and framework written in Bash

Awesome Lists containing this project

README

          

Bashd - A PoC CGI-styled web server and framework written in Bash
======

![Demo](https://github.com/AlexGustafsson/bashd/raw/master/assets/demo.png)

# Quickstart

Clone the project
```
git clone https://github.com/AlexGustafsson/bashd
```
Navigate to the folder
```
cd bashd
```
Start the server
```
./bashd
```

# Table of contents

[Quickstart](#quickstart)

[Features](#features)

[Usage](#usage)

[Contributing](#contributing)

[FAQ](#faq)

# Features

* 🔥 Not incredibly slow (300ms for a response)
* 🛣 Routing
* 📭 Easy-to-use POST support
* 🔒 Security by obscurity. Who's expecting a Bash web server?

# Usage

**Defining a route**

```bash
route get / homePage
# Special 404 route - handles all 404s
route get 404 notFoundPage
# POST a message to the echo page to hear it back louder!
route post /echo echoPage
```

**Handling pages**

```bash
function homePage {
startResponse
cat << EOF



Hello, World!


EOF
}

function notFoundPage {
setResponseCode "404"
startResponse
cat << EOF



Cannot find $HTTP_METHOD $HTTP_PATH


EOF
}

function echoPage {
startResponse
cat << EOF



${HTTP_BODY_MESSAGE^^}


EOF
}
```

# FAQ

**Q**: Does it work?
**A**: Yes.

**Q**: Is it safe?
**A**: No.

**Q**: Is it a joke?
**A**: Mostly.

# Contributing

Any help with the project is more than welcome. When in doubt, post an issue.