CGI language selection

Well, I asked a few related questions here, and I had more questions, and I understood it now, because I do not have enough information about the background. Therefore, I will make it more general:

I need to create a simple web application. Static HTML / JQuery pages will send AJAX POST requests for some server-side code, which will be:

  • Read the POST variables passed in
  • Run very simple logic
  • Hit MySQL Database for Simple CRUD Operations
  • Returns a simple string of data to be used by javascript on the page

I assumed that Ruby was a good choice for this, since everyone raves about how well it was developed, and I played with it - not RoR, but just Ruby for simple scripting tasks - and I like it.

My question is: I am hopelessly confused in trillions of supporting libraries and frameworks. I do not know what it is, and therefore, if I need all / all of them: Rack, Sinatra, Camping, mod_ruby, FastCGI, etc.

Would it be easier to just learn PHP and us? Or can I leave by simply dropping my .rb files into the cgi-bin folder (I use Apache for hosting) and use the ruby ​​cgi library to get the variables?

.: Rails, , , , . , -, , , . , - . , . HTML. , ruby ​​ script , JSON . cookie/session/state

# ASP.NET webservices, .

+3
6

- , . = = .

CGI

CGI , - (-) . cgi:

require "cgi"
cgi= CGI.new

answer= evaluate(cgi.params)

cgi.out do
    answer
end

. Rack - , - (cgi, fastcgi, webrick,...). , cgi. , .ru cgi.

#!/usr/bin/rackup
require "rack/request"

run (lambda do |env|
  request= Rack::Request(env)

  anwser= evaluate(request.params)

  return [200, {}, answer]
end)

cgi, . , - webrick. - -, .ru.

CGI

fast-cgi CGI. , CGI script , . cgi script . , fast-cgi script ruby.

mod_ruby

mod_ruby - apache. mod_php apache.

mongrel - - . .

require 'mongrel'

class SimpleHandler < Mongrel::HttpHandler
   def process(request, response)
     response.start(200) do |head,out|
       head["Content-Type"] = "text/plain"
       out.write("hello world!\n")
     end
   end
end

h = Mongrel::HttpServer.new("0.0.0.0", "3000")
h.register("/hello", SimpleHandler.new)
h.run.join

Mongrel . apache - 80. -, mongrel-, . , .

phusion

mod_rails mod_rack. apache nginx . - 1/3 , . , , , cgi fast-cgi.

+2

jQuery PHP.

, . , - - CRUD- .., . JSON, , , PHP-, JSON.

+2

. Phusion Passenger ( mod_php , Rails Sinatra). : http://blog.squarefour.net/2009/03/06/deploying-sinatra-on-passenger/

, , , Rails. Passenger , - . (. modrails.com).

+1

PHP , . POST? $_POST. MySQL? mysql_query ( "SELECT` something` FROM `table`" );. - , Google "php what_you_need_to_do" php.net, .


, , .

+1

, Rails. , " ", , , Rails - . - . , , Rails -, "", .

-, Rails . sqlite MySQL ( , ). , , , , , -, , . : , .

, , Apache... Rails , , IP- Apache. mod_fcgid, , , Apache (mod_ruby , , ), . Phusion Passenger, , , . Rails CGI ( CGI, ) - + . , -, + .

0

Django. Ruby on Rails, , - , , ( , ROR ). , Django, , , , ... , , .

, , "". Django, ROR, MVC. , . , , .

Here is their website: http://www.djangoproject.com/

0
source

Source: https://habr.com/ru/post/1723796/


All Articles