Ruby - Sinatra
Simple Server including Basic Authentication
#!/usr/bin/env ruby
require 'sinatra'
require 'erb'
# sinatra settings
set :bind, '0.0.0.0'
set :port, 4567
set :public_folder, '/tmp/public'
# add basic authentication
use Rack::Auth::Basic, 'Restricted Area' do |user, pass|
user == 'ruby' && pass == 'super_se(re1'
end
home = %q(
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="https://www.w3schools.com/lib/w3.js"></script>
<body>
<div class="w3-top w3-bar w3-black">
<a href="#home" class="w3-bar-item w3-button">Home</a>
<a href="#about" class="w3-bar-item w3-button">About</a>
<a href="#contact" class="w3-bar-item w3-button">Contact</a>
</div>
<br/><br/>
<div id="welcome" class="w3-container w3-green"><h2> Welcome </h2></div>
</body>
</html>
)
# add routes
get "/" do
ERB.new(home).result(binding)
end