Frank Sinatra Witchcraft: Lyrics, Meaning, and the Story of a Hit

Frank Sinatra Witchcraft: Build a Simple Web App with Sinatra

Okay, so I’ve been messing around with this whole “Frank Sinatra Witchcraft” thing, and let me tell you, it’s been a wild ride. I’m no expert, but I figured I’d share my little experiment, start to finish.

Getting Started

First, I needed to get the basics down. I installed Ruby, because, well, Sinatra needs Ruby. That was pretty straightforward. Then I installed the Sinatra gem using the gem install command.

I created a new folder for my project, just to keep things tidy. Inside that folder, I created a file called “*”. That’s where the magic was going to happen, or so I hoped.

The “Hello, World” Phase

Every coding adventure starts with “Hello, World,” right? So, I opened up “*” and typed in the basic Sinatra setup:

Frank Sinatra Witchcraft: Build a Simple Web App with Sinatra
  • require ‘sinatra’
  • get ‘/’ do
  • ‘Hello, world!’
  • end

Then, I jumped over to my terminal, navigated to my project folder, and typed in ruby *. Boom! I opened my web browser, typed in localhost:4567, and there it was: “Hello, world!” I felt like a coding god, even though it was just a simple message.

Adding Some Routes

Okay, “Hello, world” is cool, but it’s not exactly witchcraft. I wanted to do more. So, I added some more routes to my “*” file. I created a route for “/about” that just displayed some plain text about me. Then, I created another route for “/frank” that, of course, said something about Frank Sinatra.

Getting Fancy with HTML

Plain text is boring. I wanted this to look at least a little bit presentable. So, I learned about this thing called “ERB” (Embedded RuBy). It lets you mix HTML with Ruby code. Neat!

Frank Sinatra Witchcraft: Build a Simple Web App with Sinatra

I created a new folder called “views” and inside, I created files like “*” and “*”. Inside those files, I wrote some basic HTML, and where I wanted to display my messages, I used these special ERB tags to insert the Ruby code. For example, I put my “Hello World” in an h1 tag. Classy.

Back in my “*” file, I changed the routes to use erb :index and erb :about. This told Sinatra to render those ERB files. I restarted the server (Ctrl+C and then ruby * again), refreshed my browser, and bam! It looked like a real website, kind of.

The “Witchcraft” Part (Sort Of)

Now, for the slightly more interesting part. I wanted to show a different message on the “/frank” page depending on the time of day. Because, why not? Witchcraft is all about timing, right?

Frank Sinatra Witchcraft: Build a Simple Web App with Sinatra

So, I added some Ruby code to my “/frank” route to get the current hour. If it was morning, it would say one thing about Frank, and if it was afternoon or evening, it would say something else. It wasn’t exactly summoning demons, but it was dynamic! It changed on its own! Spooky!

The Final Product

In the end, I had a super simple website. It wasn’t going to win any awards, but it did what I wanted it to do. I could go to different pages, see some text, and even get a time-based message. I went from knowing nothing about Sinatra to having a working, albeit very basic, web application.

My main takeaway is that you do not have to know everything! Just start with the Hello World, and build it slowly, step by step, using your search engine.

Frank Sinatra Witchcraft: Build a Simple Web App with Sinatra

RELATED ARTICLES