-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathserver.ru
42 lines (37 loc) · 1009 Bytes
/
server.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env ruby
require 'net/http'
app = proc do |ev|
ret = ""
options = {}
req_path = ev['REQUEST_PATH'].split('/')
options[:user] = req_path[1]
options[:repo] = req_path[2]
options[:page] = req_path[3]
case options[:page]
when 'network_meta'
puts("=> http://github.com#{ev['REQUEST_URI']}")
ret = Net::HTTP.get('github.com', ev["REQUEST_URI"])
typ = 'text/json'
when 'network_data_chunk'
puts("=> http://github.com#{ev['REQUEST_URI']}")
ret = Net::HTTP.get('github.com', ev["REQUEST_URI"])
typ = 'text/json'
when 'network.js'
ret = File.read('network.js')
typ = 'text/javascript'
when 'network'
ret = File.read('index.html')
typ = 'text/html'
when 'jquery-1.3.2.min.js'
ret = File.read('jquery-1.3.2.min.js')
type = 'text/javascript'
else
nil
end
return [ 200,
{'Content-Type' => typ,
'Content-Length' => ret.length.to_s},
[ret] ]
end
use Rack::CommonLogger
run app