-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.rb
45 lines (39 loc) · 909 Bytes
/
index.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
39
40
41
42
43
44
45
require 'sinatra'
require 'RMagick'
helpers do
include Rack::Utils
alias_method :h, :escape_html
end
get '/' do
erb :index
end
post '/' do
if params[:number] and not params[:number].empty?
@number = params[:number]
end
erb :index
end
get '/favicon.ico' do
end
get '/:style/:number.:format' do
content_type 'image/png'
il = Magick::ImageList.new
params[:number].each_char do |number|
il.push(Magick::Image.read("images/" + params[:style] + "/" + number + ".png").first)
end
img = il.append(false)
img.format = 'png'
img.to_blob
end
get '/:number.:format' do
content_type 'image/png'
il = Magick::ImageList.new
puts params[:number]
puts params[:format]
params[:number].each_char do |number|
il.push(Magick::Image.read("images/red/" + number + ".png").first)
end
img = il.append(false)
img.format = 'png'
img.to_blob
end