Sha256: f67b276cc4bdc111ab42724237fb0a0d5b246bcf99885461c21f58ba0ec352e9
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module StatsLite class App < Sinatra::Base before do password = params[:password] || request.cookies["stats_lite_password"] conf_pass = StatsLite.configure.password if conf_pass && conf_pass != password if session[:stats_lite_password] session[:stats_lite_password] = nil end next halt 404, { "Content-Type" => "text/plain" }, "" end unless session[:stats_lite_password] set_session(password) end end def set_session(password) response.set_cookie "stats_lite_password", password end get "/" do content_type :json result.to_json end private def result default = Default result = { time_utc: Time.now.utc.strftime("%e %b %Y %H:%M:%S%p").strip, host: default.host, cpu: default.cpu, ram: default.ram, hdd: default.hdd } data = StatsLite.configure.data data.call(result) if data result end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stats_lite-0.7.1 | lib/stats_lite/app.rb |