-
Notifications
You must be signed in to change notification settings - Fork 0
/
heroku-sinatra-app.rb
53 lines (43 loc) · 1.1 KB
/
heroku-sinatra-app.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
46
47
48
49
50
51
52
53
# You'll need to require these if you
# want to develop while running with ruby.
# The config/rackup.ru requires these as well
# for it's own reasons.
#
# $ ruby heroku-sinatra-app.rb
#
require 'rubygems'
require 'sinatra'
configure :production do
# Configure stuff here you'll want to
# only be run at Heroku at boot
# TIP: You can get you database information
# from ENV['DATABASE_URI'] (see /env route below)
end
get '/' do
return File.open("public/index.html")
end
post '/levels' do
end
post '/level/:id' do
f = File.new("levels/level_"+ params[:id], 'w')
f.puts(params[:code])
f.close
redirect '/customise.html'
end
get '/javascripts/levels2.js' do
levels = []
d = Dir.new('levels')
d.each do |f|
unless ['.', '..'].include?(f)
levels << File.open('levels/'+ f).read
end
end
return 'var levels = ['+levels.join(",\n")+']'
end
# Test at <appname>.heroku.com
# You can see all your app specific information this way.
# IMPORTANT! This is a very bad thing to do for a production
# application with sensitive information
# get '/env' do
# ENV.inspect
# end