-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
45 lines (36 loc) · 1.01 KB
/
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
require 'rubygems'
require 'sinatra'
require 'json'
# do nothing for now, we're just serving static content
# TODO automatically build the manifest file
gem 'activerecord','2.3.8'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:host => "localhost",
:username => "root",
:password => "root",
:database => "study_language"
)
get '/' do
#f=File.new('/home/zuoyonghui/projects/sencha/study_language/GRE-Deck.txt','r')
#f.each_line do |line|
# Word.create(:english =>line.split("\t")[0],:chinese=>line.split("\t")[1].split("\n")[0])
#end
redirect '/index.html'
#erb :index
end
get '/words' do
content_type :json
Word.find_by_sql(["select * from words order by english offset ? limit ? ", params[:start], params[:limit]]).to_json
end
get '/loads' do
content_type :json
p "-------------"
Word.all[7000,1000].to_json
end
get '/db_dash_panel' do
erb :db_dash_panel
end
class Word < ActiveRecord::Base
end