Skip to content

Instantly share code, notes, and snippets.

@migane
Created September 6, 2012 10:56
Show Gist options
  • Save migane/3654789 to your computer and use it in GitHub Desktop.
Save migane/3654789 to your computer and use it in GitHub Desktop.
Reverse world in sentence with rackup
# config.ru
require './my_app_bis.rb'
run MyAppBis.new
# my_app_bis.rb
class MyAppBis
def initialize()
@str = "Is not rackup fun, is it?"
end
def reverse_word(str)
str.split(" ").reverse.join(" ")
end
def call(env)
[200, {"Content-Type" => "text/html"}, [
"<head>",
"<style type=\"text/css\">",
"h1 {color: #8B4513;}",
"h2 {margin-left: 45px;color: #5F9EA0;}",
"b.foo {padding-left: 20px;}",
"b.bar {padding-left: 95px;}",
"</style>",
"</head",
"<body>",
"<h1>Reverse Word Order in Sentence Service</h1>",
"<p>The initial sentence was: <b class=\"foo\">#{@str}</b></p>",
"<p>The result is: <b class=\"bar\">" + reverse_word(@str)+ "</b></p>",
"<h2>And the coder is doubled up with laughter.</h2>",
"</body>"]]
end
end
# Comments
# Would have preferred to use linked stylesheet, but don't know how to tell rackup
# to serve it.
@DouglasAllen
Copy link

@DouglasAllen
Copy link

I think if you treat it just like a sinatra app and make a public folder with your stylesheets in a stylesheets folder, you might give that a try.

@DouglasAllen
Copy link

I'm getting h1 and h2 to work but the color is not

@DouglasAllen
Copy link

Be sure to use single quotes
"",

@DouglasAllen
Copy link

"",

@DouglasAllen
Copy link

["",]

@DouglasAllen
Copy link

I can't seem to figure out the markdown here. But you know what I mean.

@DouglasAllen
Copy link

What I tried to let you know was that I don't get any syntax errors with a line like this
link rel='stylesheet' href='/public/stylesheets/style.css'/
however you're right it just won't link. I tried the folders like stated previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment