lib/template/config.ru in browser_app_base-0.1.0 vs lib/template/config.ru in browser_app_base-0.1.1
- old
+ new
@@ -6,14 +6,11 @@
require "json"
require "./server"
require "./wsserver"
-temp_dir = ENV["temp"]
-temp_dir = "/tmp" if temp_dir == nil
-puts "temp_dir=#{temp_dir}"
-access_log = File.new("#{temp_dir}/logs/sinatra.log", "a+")
+access_log = File.new("#{$home_dir}/logs/sinatra.log", "a+")
access_log.sync = true
use Rack::CommonLogger, access_log
get "/" do
File.read("html/index.html")
@@ -37,18 +34,22 @@
end
get "/config/*.*" do |file, ext|
content_type "text/json", :charset => "utf-8"
puts "#{file}.#{ext}"
- File.read "config/#{file}.#{ext}"
+ File.read "#{$home_dir}/config/#{file}.#{ext}"
end
post "/history/*.*" do |file, ext|
content_type "text/json", :charset => "utf-8"
puts "#{file}.#{ext}"
p = params[:param1]
- buf = File.read "history/#{file}.#{ext}"
+ begin
+ buf = File.read "#{$home_dir}/history/#{file}.#{ext}"
+ rescue
+ buf = ""
+ end
data = eval(buf)
if data != nil
if p != ""
JSON.generate data.find_all { |d| d =~ Regexp.new(p) }
else
@@ -99,8 +100,8 @@
# Thread.start {
# }
end
-#\ --port 36809
+#\ --port 58656
run Sinatra::Application