Created
June 30, 2014 18:10
-
-
Save jrunning/ddc026df5d50645ae24e to your computer and use it in GitHub Desktop.
Instant Ruby CGI server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "webrick" | |
server = WEBrick::HTTPServer.new(Port: 8080, DocumentRoot: Dir::pwd) | |
trap("INT") { server.shutdown } | |
server.start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "cgi" | |
NUM_LINES = 20 | |
FILE_TO_TAIL = "/var/log/system.log" | |
COMMAND = "| tail -#{NUM_LINES} #{FILE_TO_TAIL}" | |
cgi = CGI.new | |
open(COMMAND) {|io| cgi.out("text/plain", &io.method(:read)) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment