Book Image

Implementing AppFog

Book Image

Implementing AppFog

Overview of this book

AppFog is the leading platform-as-a-service provider of PHP, Ruby, Node.js, and Java solutions. It is used by developers worldwide to deploy tens of thousands of applications. AppFog delivers a reliable, scalable, and fast platform for deploying applications in the cloud.This book is a hands-on guide that will walk you through creating and deploying applications to the cloud using AppFog, which will allow you to get your application deployed without the hassle of setting up servers.This book demonstrates how to use the AppFog service to build an application and have it running in the Cloud. It will walk you through the initial AppFog setup process and explain how to create your first application in minutes.You will also discover how to use services such as databases to make your applications more powerful. You will also learn how to create applications from scratch.You will find out everything you need to know to get an application running in the cloud for the first time.
Table of Contents (13 chapters)
Implementing AppFog
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating an application


We could use the application we created and downloaded in Chapter 2, Using the Command Line Tool, however we are going to create a very new application. This application is also going to be a Sinatra application that displays some basic date and time information.

First, navigate to a new directory that will be used to contain the code. Everything in this directory will be uploaded to AppFog when we create the new application.

$ mkdir insideaf4
$ cd insideaf4

Now, create a new file called insideaf4.rb. The contents of the file should look like the following:

require 'sinatra'

get '/' do
  erb :index
end

As we saw in the previous chapter, this tells Sinatra to listen for requests to the base URL of / and then render the index page that we will create next.

If you are using Ruby 1.8.7, you may need to add the following line at the top, as described in Chapter 2, Using the Command Line Tool:

require 'rubygems'

Next, create a new directory called views under the insideaf4 directory...