-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
37 lines (31 loc) · 1.02 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
#encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
get '/' do
erb "Hello! <a href=\"https://github.com/bootstrap-ruby/sinatra-bootstrap\">Original</a> pattern has been modified for <a href=\"http://rubyschool.us/\">Ruby School!!</a>"
end
get '/about' do
erb :about
end
get '/visit' do
erb :visit
end
get '/contacts' do
erb :contacts
end
post '/visit' do
@user_name = params[:user_name]
@user_phone = params[:user_phone]
@user_date_visit = params[:user_date_visit]
@master = params[:selected_master]
@color = params[:color]
File.open('./public/visit.txt', 'a'){|f| f.write("#{@user_name},#{@user_phone},#{@user_date_visit},#{@master}, #{@color}\n")}
erb "OK, username is #{@user_name}, #{@user_phone}, #{@user_date_visit}, #{@master}, #{@color}"
end
post '/contacts' do
@user_mail = params[:user_mail]
@user_feedback = params[:user_feedback]
File.open('./public/contacts.txt', 'a'){|f| f.write("Begin\n#{'=' * 20}\n#{@user_mail}\n#{@user_feedback}\n#{'=' * 20}\nEnd\n")}
erb :contacts
end