-
-
Save ajuckel/e71006e05d75796ddd8b to your computer and use it in GitHub Desktop.
Sinatra sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
get '/' do | |
erb :index | |
end | |
post '/' do | |
session = login(params[:username], params[:password]) | |
erb :index | |
end | |
def login(username, password) | |
@username = username | |
@password = password | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<% if @username && @password %> | |
<ul> | |
<li>Username: <%= @username %></li> | |
<li>Password: <%= @password %></li> | |
</ul> | |
<% end %> | |
<form action="/" method="post"> | |
<input type="text" label="username" name="username" /> | |
<input type="password" label="password" name="password" /> | |
<input type="submit" /> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment