Ruby ワンライナーで簡易ウェブサーバを起動する
はじめに
Ruby ワンライナーで簡易ウェブサーバを起動する方法についてのメモ。
環境
$ hostnamectl status
Static hostname: ---
Icon name: computer-container
Chassis: container
Machine ID: ---
Boot ID: ---
Virtualization: lxc
Operating System: Ubuntu 20.04.2 LTS
Kernel: Linux 5.4.0-67-generic
Architecture: x86-64
$ ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
ワンライナー
--port
オプションでポート指定が可能。
$ ruby -run -e httpd . --port 8080
[2021-03-26 15:24:35] INFO WEBrick 1.4.2
[2021-03-26 15:24:35] INFO ruby 2.6.6 (2020-03-31) [x86_64-linux]
[2021-03-26 15:24:35] INFO WEBrick::HTTPServer#start: pid=599 port=8080
About
関西在住のエンジニア
言語: Ruby・Go・PHP
フレームワーク: RoR・Gin
趣味: 自作PC