-
Notifications
You must be signed in to change notification settings - Fork 23
/
config.ru
40 lines (33 loc) · 1017 Bytes
/
config.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
require 'bundler/setup'
require 'rails'
require 'action_controller/railtie'
require 'net/http'
require 'uri'
class TheSmallestRailsApp < Rails::Application
routes.append { root to: 'hello#world' }
config.secret_token = 'a'*30
config.logger = Logger.new STDOUT
end
class HelloController < ActionController::Base
def world
uri = URI.parse 'http://hilite.me/api'
form = {'lexer' => 'ruby', 'code' => File.read(__FILE__)}
response = Net::HTTP.post_form uri, form
render inline: %Q{
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Smallest Rails App</title>
</head>
<body>
<h3>I am the smallest rails app!</h3>
<p>Here is my source code:</p>
<p>#{response.body}</p>
<a href="https://github.com/artemave/thesmallestrailsapp.com">Make me smaller</a>
</body>
</html>
}
end
end
TheSmallestRailsApp.initialize! rescue false # what could possibly go wrong?
run TheSmallestRailsApp