LoginSignup
2
1

More than 5 years have passed since last update.

Webの言語とは 〜Bashをwebの言語にする〜

Last updated at Posted at 2018-03-06

(元記事はこっち:http://www.hakopako.net/entry/2018/03/07/001400

Webの言語とは

身内でも話題になったので。
webの言語とはなにを指しているのだろうと考えたのだけれど、
ブラウザを介した通信で実行できる言語 のことを言っているのかなと解釈した。

 

> Bash も webの言語になれるかもしれない <

bashでjsonを返してみようと思う。

  • body.sh
#!/bin/bash
# body.sh

echo '{"message": "Hello World !!!"}'
  • header.sh
#!/bin/bash
# header.sh

echo 'HTTP/1.1 200 OK;'
echo 'Content-Type application/json;\r\n'
  • webサーバ起動
$ while true; do { sh header.sh; sh body.sh; } | nc -l 8080; done

 

webの言語になれました。
webbash.png

以上、bashでwebサーバを起動する方法 Bashをwebの言語にする方法でした。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1