FalconGuidesGetting Started

Getting Started

This guide gives an overview of how to use Falcon for running Ruby web applications.

Installation

Add the gem to your project:

$ bundle add falcon

Or, if you prefer, install it globally:

$ gem install falcon

Core Concepts

Falcon is a high-performance web server for Ruby. It is designed to be fast, lightweight, and easy to use.

Rack

Falcon is a Rack server. This means it can run any Rack application, including Rails, Sinatra, and Roda. It is compatible with the Rack 2 and Rack 3 specifications. Typically these applications have a config.ru file that defines the application. Falcon can run these applications directly:

# config.ru

run do |env|
	[200, {'Content-Type' => 'text/plain'}, ['Hello, World!']]
end

Then run the application with:

$ falcon serve

Running a Local Server

For local application development, you can use the falcon serve command. This will start a local server on https://localhost:9292. Falcon generates self-signed certificates for localhost. This allows you to test your application with HTTPS locally.

To run on a different port:

$ falcon serve --port 3000

Unencrypted HTTP

If you want to run Falcon without TLS, you can use the --bind option to bind to an unencrypted HTTP endpoint:

$ falcon serve --bind http://localhost:3000

Using with Rackup

You can invoke Falcon via rackup:

$ rackup --server falcon

This will run a single-threaded instance of Falcon using http/1. While it works fine, it's not recommended to use rackup with falcon, because performance will be limited.