...
 
Commits (2)
require 'sinatra'
#require 'sinatra/cross_origin'
def font_validation(font)
dir = Dir.entries('./public/fonts')
if dir.include? font
return true
else
return false
end
end
set :bind, '0.0.0.0'
set :public_folder, 'public'
set :protection, except: :frame_options
......@@ -20,6 +29,10 @@ options "*" do
200
end
error 403 do
'Access is forbidden.'
end
get '/' do
'Please use GET /fonts?font=FONTNAME to get your stylesheet'
......@@ -29,9 +42,16 @@ get '/fonts' do
headers({'X-Frame-Options' => 'SAMEORIGIN', 'Timing-Allow-Origin' => '*'})
cache_control :private, :max_age => 86400
content_type "text/css"
f = File.open("public/stylesheets/#{params[:font]}.css")
f.read
if params.has_key?(:font)
if font_validation(params[:font])
f = File.open("public/stylesheets/#{params[:font]}.css")
f.read
else
403
end
else
403
end
end