-
Notifications
You must be signed in to change notification settings - Fork 0
/
life.rb
41 lines (32 loc) · 825 Bytes
/
life.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
#life.rb
require 'sinatra'
require 'mysql2'
enable :sessions
client = Mysql2::Client.new(
:adapter => 'mysql',
:host => 'localhost',
:username => 'ronald',
:password => 'dev',
:database => 'life'
)
get '/' do
#puts settings.root
#send_file File.join(settings.root, 'public/life.html')
#"settings.public is this: " + settings.public
#":views is this: " + settings.root
"this is the session: " +
session["user"] ||= nil
end
post '/new_user' do
email = params[:email]
pass = params[:pass]
client.query("insert into users (id, email, pass) values('', '#{email}', '#{pass}');");
#return result;
#"This is yon mail #{params[:mail]}"
#"This is yon pw #{params[:pw]}"
end
# login and logout
post '/login'
session["user"] ||= params[:name]
post '/logout'
session["user"] ||= nil