shortcuts:
TOC
NanoTwitter
search:
Intro to Sinatra
(Thu Jan 27, lect 4)
|
previous
|
next
|
slides
|
Sinatra is a ruby application server
Logistics
What to do if you are unable or late submitting an assignment
What to do if you need an excused absence
Remember we are
in person
next week. Room: Shapiro Science Center 014
What is Sinatra?
A ruby library
Easiest way to create a simple web server
Much smaller and easy to understand than rails (also less powerful)
What is Sinatra according to their own
Sinatra Intro
The Sinatra app
Review Web Server (or http server) vs. Application Server
Single main ruby program
Filters (before, after)
Discuss the role of
Rack
and Rackup
Logging
Browser caching
Configuration
Running sinatra for different
environments
APP_ENV=production ruby my_app.rb
Testing - using minitest
Modular vs. Classic Style Apps
Routing
One method for each “route”
Rendering of Views
Routes with parameters
Routes with patterns
Sessions to cary information from one request to the next
Nice pattern matching to generalize similar routes
At the end of the method, either render html, json, or redirect
Passing parameters to view templates
Each of the route methods are “kind of like” a controller
Data
Sinatra doesn’t do anything special about working with the database
Whatever database access you prefer will work
Our examples use ActiveRecord as a library to interface with the database
But there are other ones that work just as well
Typical design
encapsulates the data access in a class
one class for each table or entity
often referred to as a model class
Views
Erb is a very common templating language
Look at
ERB Cribsheet
They are what is generated at the end of the route method
In addition to erb there are tons of others
What they have in common: they all generate data (in the end) that is returned as the result of an HTTP request
Thank you. Questions?
(random Image from picsum.photos)
Intro
Cosi105 - Scalability 2022 Syllabus
List of lectures
nanoTwitter
Homeworks
Lectures
Web Apps + Sinatra
Welcome
What is Scalability?
Cosi166 Quick Bullets
Intro to Sinatra
Sinatra and Twitter
NanoTwitter introduced
nano Twitter
Starting to think about scaling
Scaling at Hubspot
Service Oriented Architecture
Deploying to the Cloud
Scalable Service design
Scalability, continued
Testing in the world of SOA
Scaling Patterns
Testing Scalability
Tuning for Scale
Logging
Caching
Database Tuning 1
Database Tuning 2
Concurrency 1
Concurrency 2
Queueing
SOA + µservices
Software Engineering
Scalability Runoff 1
Last class!
Background
Technical Presentations
Misc Links and Resources