Search code examples
rubysinatranearlyfreespeech

How do I set up Sinatra or another Ruby framework on NearlyFreeSpeech


How would I get the following code to work properly on a site hosted on NearlyFreeSpeech.net?

require 'sinatra'

get '/' do 
    "Hello world!"
end

That code is in a script file named main.rb, which is in the public folder on my NSFN-hosted site.

But when go to my site, I get a 403 error.

If this worked, it would show Hello world!.

What am I doing wrong?


Solution

  • Update: They added support for ruby it should be possible to run your ruby code https://blog.nearlyfreespeech.net/2014/09/24/more-power-more-control-more-insight-less-cost/

    Original Answer:

    Short answer to how you can make that happen: You can't.

    Just use heroku or openshift or any other provieder which allow you to run ruby (the have both free tiers)

    Since your next question is probably why you can't do that:

    It's because how web server in combination with something like php, ruby, python works. A web server can only write characters to a connected user (yes I simplify here) so you need translate your script in to character. Also known as run your script. And to make that happens your hoster need to support this (as in they have ruby installed), in your case they support just php so you can't run ruby code.