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
- Host: GitHub
- URL: https://github.com/alexgustafsson/bashd
- Owner: AlexGustafsson
- License: unlicense
- Created: 2019-04-17T09:16:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-14T14:22:11.000Z (almost 5 years ago)
- Last Synced: 2025-01-19T07:23:36.544Z (over 1 year ago)
- Topics: cgi, proof-of-concept, webserver
- Language: Shell
- Size: 89.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Bashd - A PoC CGI-styled web server and framework written in Bash
======

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)
* 🔥 Not incredibly slow (300ms for a response)
* 🛣 Routing
* 📠Easy-to-use POST support
* 🔒 Security by obscurity. Who's expecting a Bash web server?
**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
}
```
**Q**: Does it work?
**A**: Yes.
**Q**: Is it safe?
**A**: No.
**Q**: Is it a joke?
**A**: Mostly.
Any help with the project is more than welcome. When in doubt, post an issue.