-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor_server.rb
40 lines (30 loc) · 1.06 KB
/
monitor_server.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
# encoding: utf-8
require "sinatra"
require "mongo"
MongoConn = Mongo::Connection.new "localhost", 27017
DB = MongoConn.db "uplayer"
Coll = DB.collection "status"
get "/" do
"<br/> <br/> <br/> 私人领地,闲人莫入! <br/><br/> <br/> ------Andersen Fan([email protected])"
end
get "/dalaoju" do
@per_page = 20
@logs = Coll.find.sort(["created_at","descending"]).skip([(params[:page].to_i-1)*@per_page,0].max).limit(@per_page)
erb :log, locals: {page: params[:page], logs: @logs}
end
get "/dlj" do
@per_page = 50
@logs = Coll.find.sort(["created_at","descending"]).skip([(params[:page].to_i-1)*@per_page,0].max).limit(@per_page)
erb :dlj, locals: {page: params[:page], logs: @logs}
end
get "/dl" do
@per_page = 100
@logs = Coll.find.sort(["created_at","descending"]).skip([(params[:page].to_i-1)*@per_page,0].max).limit(@per_page)
erb :dl, locals: {page: params[:page], logs: @logs}
end
post "/dalaoju" do
params[:created_at] = Time.now
Coll.insert params
"successfully logged @#{Time.now}"
end
private