learn-co-curriculum / what-is-sinatra Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
This lesson wasn't able to load up the sinatra server when a student did ruby app.rb
. On as screen share I discovered that ENV["HOST_PORT"]
was returning nil
, most likely because this key was removed from or changed in ENV hash. I was able to get Sinatra to work by manually passing in an port number but this could potentially cause more issue for students in the future.
When students run rackup
or shotgun
in the IDE to start a Sinatra server, the command is properly intercepted and routed on the backend. However, when students run ruby app.rb
it isn't, and it results in the following failure:
[02:01:30] (master) sinatra-hello-world-basics-v-000
// โฅ ruby app.rb
== Sinatra (v1.4.7) has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.7.0 codename Dunder Mifflin)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop
Stopping ...
== Sinatra has ended his set (crowd applauds)
/usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:530:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:530:in `start_server'
from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/backends/tcp_server.rb:16:in `connect'
from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/backends/base.rb:63:in `block in start'
from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run_machine'
from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run'
from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/backends/base.rb:73:in `start'
from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/server.rb:162:in `start'
from /usr/local/rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/handler/thin.rb:19:in `run'
from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:1506:in `start_server'
from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:1444:in `run!'
from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/main.rb:25:in `block in <module:Sinatra>'
Have to either change that functionality or the README for this lesson, which instructs students to start this web application by running ruby app.rb
.
cc: @aturkewi
P.S.: Props to @mekowalski for (apparently) being the only student using the IDE to actually try to follow the instructions! ๐
The last paragraph of Why Sinatra Before Rails has a duplicate clause: "a system for building web applications that governs 90% of the worlds' apps." It's in both the first and last sentence.
Refer to Readme for content outline
deadline - Thursday 9/17/2015
output looks like this
[2019-03-31 14:45:45] INFO WEBrick 1.4.2 [2019-03-31 14:45:45] INFO ruby 2.6.1 (2019-01-30) [x86_64-darwin18] [2019-03-31 14:45:45] INFO WEBrick::HTTPServer#start: pid=69165 port=9292 ^C[2019-03-31 14:45:55] INFO going to shutdown ... [2019-03-31 14:45:55] INFO WEBrick::HTTPServer#start done.
not
`$ rackup app.rb
Puma starting in single mode...
and not
The lesson says after you do gem install sinatra
and set up your app.rb
to be (if you're on the IDE):
require 'sinatra'
# Add these two lines below if you're on the Learn IDE!
set :bind, ENV["HOST_IP"]
set :port, ENV["HTTP_PORT"]
get '/' do
"Hello, World!"
end
Then when you run ruby app.rb
you should have a running Sinatra server on SOME_IP:SOME_PORT
, but instead, this is coming up:
// โฅ ruby app.rb
== Sinatra (v2.0.0) has taken the stage on for development with backup from Thin
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on 67.205.130.239:8080, CTRL+C to stop
Stopping ...
== Sinatra has ended his set (crowd applauds)
/usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.5/lib/eventmachine.rb:530:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.5/lib/eventmachine.rb:530:in `start_server'
from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.2/lib/thin/backends/tcp_server.rb:16:in `connect'
from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.2/lib/thin/backends/base.rb:63:in `block in start'
from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.5/lib/eventmachine.rb:194:in `run_machine'
from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.5/lib/eventmachine.rb:194:in `run'
from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.2/lib/thin/backends/base.rb:73:in `start'
from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.2/lib/thin/server.rb:162:in `start'
from /usr/local/rvm/gems/ruby-2.3.1/gems/rack-2.0.3/lib/rack/handler/thin.rb:22:in `run'
from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-2.0.0/lib/sinatra/base.rb:1522:in `start_server'
from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-2.0.0/lib/sinatra/base.rb:1456:in `run!'
from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-2.0.0/lib/sinatra/main.rb:26:in `block in <module:Sinatra>'
If I ran: echo $HTTP_PORT
it showed up blank, so I tried substituting RACK_PORT
and hard-coding a port# instead of HTTP_PORT
, but just got the same message but for a different port.
The overview- "How does Twitter have different pages for each of its 300 million users? How can AirBnB support over 40 million guests with over 1.5 million listings worldwide? All of this is possible because of web applications"- is never addressed again in the rest of the readme. It feels almost like a non sequitur
Answering that first in the "What's a Web Framework" section would ease the reader in better to the rest of the info in there, and might also motivate them to keep going further into the readme. Or can we make Web Frameworks its own separate Readme, and in there, you can compare Rails vs. Sinatra as well as why pedagogically, teaching Sinatra first makes sense.
I think then this Sinatra Readme can just cover them creating the simple Sinatra app, which while pedagogically not that useful maybe, will show them the "magic" of seeing something on the web.
Hello,
in the readme it says to comment out two lines if running from learn IDE... however, it only works when I uncommented the two lines.
Since the last unit before the unit on Sinatra is on OO, there are a couple of knowledge gaps that should be addressed.
^^ Add "libraries of code" since having "libraries alone can be confusing.
Suggest Wikipedia or other link that explains DSL. Student won't know what Rack is or Rails. Also, can we assume that they know what a Full Stack Development Framework is?
^^ Unclear whether the student should actually make this file and run it.
^^ Will students know what "listening to HTTP requests" mean? Unclear what a port is and how port 4567 is the Sinatra default.
^^ Really unsure what this application structure is? Should it be broken apart a bit moer? Also, "modular style encapsulated by Controller Classes and booted via the config.ru Rack convention" makes no sense to me right now. In addition to tweaking the language slightly, could be worth mentioning that these things will be mentioned in the next readme.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.