/
server.rb
38 lines (32 loc) · 913 Bytes
/
server.rb
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
# This ruby script is a server that can do really weird things.
require 'sinatra'
# Use the port that has (or hasn't) been specified as an arg.
if !ARGV[0]
abort 'YOU FOOL THERE\'S NO PORT SPECIFIED'
end
set :port, ARGV[0]
# Ok just send the homepage normally
get '/?' do
erb :main
end
# But if they want org data, run the orgs tool and send that data with the
# homepage :D
get '/orgs/?' do
data = `python main.py orgs #{params['username']}`
erb :main, :locals => {:data => data}
end
# Oh hey, we can compile that java thing as well.
get '/compile/?' do
data = `python main.py compile`
erb :main, :locals => {:data => data}
end
# Oh hey, we can run that java thing as well.
get '/java/?' do
data = `python main.py java`
erb :main, :locals => {:data => data}
end
# Oh waaaat? Node JS as well? Damndamndamn.
get '/node/?' do
data = `node njs.js`
erb :main, :locals => {:data => data}
end