-
Notifications
You must be signed in to change notification settings - Fork 0
/
sl11_drone.rb
54 lines (36 loc) · 1.44 KB
/
sl11_drone.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
46
47
48
49
50
51
52
53
#encoding: utf-8
require 'sinatra'
require 'sinatra/reloader'
require 'pp'
# SL11. The big user brother
# Drones for everything. Control. 1984. Like the novel? No, reality! We are constantly being watched, so at least brush your hair perfectly!
# The thing is, some an activist hacker organization hires you to design a platform were everyone can sign up and, more importantly,
# ¡everyone can see everyone! If the government has this power, everyone should!
# So. Implement a Sinatra web application where:
# - In “/“, you can see the list of users (showing their name) that have signed up and the number of users.
# - Also in “/“, there’s a form (pointing to “/signup”) with which you can sign up yourself. After you sign up, your user id (and your id only) is saved in session, and you can see it in the top (hint: use an internal data structure were you can save ids with their corresponding names and, important: ids should be incremental and not repeat).
# - There also a “/cats” page, linked from “/“, with five pictures of cats of your choice. Do your best!
class User
@@num_user = 0
attr_accessor :user, :id
def initialize(user)
@user = user
@@num_user += 1
@id = @@num_user
end
end
class UsersList
def initialize
@user_list = {}
end
end
enable :sessions
get '/' do
@user_list
session[:message] = "Logged succesfully"
redirect to ('/signup')
erb :dronemain
end
post '/signup' do
session[:message]
end