-
Notifications
You must be signed in to change notification settings - Fork 0
Step by step guide: Your first Racket application
Lars Olsson edited this page Dec 6, 2015
·
2 revisions
Creating a Racket application involves just a few simple steps:
1. Make sure that Racket is installed correctly. The easiest way is to use Rubygems. To install Racket using Rubygems, enter the command
gem install racket-mvcin your terminal. This will try to install Racket globally on your system. If you do not have permission to install gems globally on your system, please have a look at RVM for how to install gems as an unprivileged user.
2. Create a new directory for your Racket application.
mkdir myapp3. Enter the newly created directory.
cd myapp4. Create a new text file and name it config.ru. Copy the text below into the file and save it.
require 'racket'
run Racket::Application.default
```
5\. Create a new directory **inside** the current directory called `controllers`.
```bash
mkdir controllers
```
6\. Create a new text file and name it as `controllers/main.rb`. Copy the text below into the file and save it.
```ruby
class MainController < Racket::Controller
def index
'Hello, world!'
end
end
```
7\. Now you are ready to try your new Racket application! Type
```bash
rackup
```
in the terminal. Three lines of text will appear. This is ruby's built-in web server, _webrick_, telling you that it is ready to accept connections. Now, open your web browser and navigate to **http://localhost:9292** and you should be greeted by the message "Hello, world!". If you don't see that text, something has gone wrong and you should try this guide again from the top.
8\. When you are ready for diving deeper into Racket you can stop webrick by pressing `Ctrl + C` in the terminal window.