1

I am trying to see if I can create a simple website, like a blog, using only Ruby. No Rails or a database or outside web servers. I plan to store the data in a file for persistence.

I wanted to use TCPServer, CGI, and Net::HTTP.

Is there an easier way I can use?

1

2 Answers 2

3

There are a lot of moving parts when designing a website.

Depending on the purpose of the exercise, you might want to consider using a very simple web framework like Camping, Sinatra, or Ramaze. This is probably the best solution if you're trying to get a top level understanding of web programming because it only has exactly what you need (Camping is less than 4k!) and handles stuff like routing.

Building a web server is more an exercise in HTTP parsing. You might want to omit the framework and try to build something on top of Rake (an API for lots of popular web servers) and a simple web server like Webrick or Thin.

Sign up to request clarification or add additional context in comments.

6 Comments

+1. I agree. It's better to learn about the overall design and technology, than to worry about the mechanics of the server itself. Sinatra is a great starting point, where you'll learn techniques you'd use in Rails. If you want to avoid packages like Sinatra, then using CGI to build some Ruby-based CGIs to run under nginx or Apache is a great learning experience also.
There is a sinatra wiki project which uses files to store the pages sinatra_wiki.
I think this would be tagged homework so I guess no sinatra or other frameeworks allowed either.
I don't think this is homework. It seems like a very natural thing to want to do when you're new to web programming to get an idea of how everything works.
Thanks! for all your replies. This is for fun and at the same time wanted to understand how this can be done. I looked at rails, but I thought I first build something like a simple blog with a filesystem as storage and use native ruby libraries. I am good at perl and thought of trying ruby too. I will use cgi and net/http and give a try. Please let me know if you have any other points. Thanks again.
|
0

You could also try Espresso

It is easy to learn and fast to run.

And offers all the liberty you need for creation process.

Also it has no hidden "fees", everything is transparent.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.