Use !#bash scripts for writing beautiful web apps
Features
- easy to use
<?bash echo "hello world" ?>
- write fast Web Apps in pure #!bash script
- QUERY_STRING and POST_STRING variables can used as normal bash variables (e.g example?var1=foo&var2=bar&var3=nase becomes to echo “${var1} ${var2} ${var3})
- Function for decoding URL-encoding: var_dec=$(urldecode $var1)
- Bash for Web Applications
Install Apache2
apt-get update; apt-get install -y apache2
tee /etc/apache2/sites-enabled/000-default.conf >/dev/null <<EOF
<VirtualHost *:80>
ServerName example.org
ServerAdmin webmaster@example.org
DocumentRoot /var/www/html/
ScriptAlias "/index.html" "/usr/lib/cgi-bin/index.cgi"
ScriptAlias "/index" "/usr/lib/cgi-bin/index.cgi"
RedirectMatch 404 .*\.htsh
<Directory /var/www/html/>
AllowOverride none
Options -Indexes
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
Include conf-available/serve-cgi-bin.conf
</VirtualHost>
EOF
a2enmod cgid
service apache2 restart
install BoS
git clone https://github.com/tinoschroeter/bash_on_steroids.git /var/www/newProject
cd /var/www/newProject
./bos
Usage
All bash codes are to be enclosed within <?bash ... ?> or in short, <? ... ?>
tags.
<!DOCTYPE html>
<html>
<body>
<ul>
<?bash
for i in Buzz Rex Bo Hamm Slink Potato; do
echo "<li>$i</li>"
done
?>
</ul>
</body>
</html>
Decode URL-encoding
transform this %23%21%2Fbin%2Fbash to that #!/bin/bash
example:
var_dec=$(urldecode $var)
https://en.wikipedia.org/wiki/Percent-encoding
build
$ ./bos.sh
$ index.htsh --->> /usr/lib/cgi-bin/index.cgi
Vagrant
git clone https://github.com/tinoschroeter/bash_on_steroids.git
cd bash_on_steroids
vagrant up
open http://localhost:8080/
DEMO
- Vote Star Trek vs Star Wars (ready) source
- QR Code Generator (ready) source
- Environment Variables (ready) source
- guestbook (ready) source
- Markdown Wiki (ready) source
- login (ready) source
- VM Management tool (not ready) source
- WLAN config tool (ready) source
- todo (not ready) source