sinatra

Disable Sinatra standard output

六月ゝ 毕业季﹏ 提交于 2019-12-23 13:07:55
问题 For security reasons I don't wish to have Sinatra print every URL its requested in standard output, I've tried using set :logging, false as suggested in this answer using: class SweetAppName< Sinatra::Base set :show_exceptions, false set :environment, :production set :logging, false However when I run the app using rackup and thin, I still see the request logged to the terminal: 127.0.0.1 - - [26/May/2015:09:32:34 -0700] "GET /not-a-real-url HTTP/1.0" 404 - 0.0452 How can I turn these off?

Mechanize & Sinatra conflict

我只是一个虾纸丫 提交于 2019-12-23 10:42:22
问题 I've writter a simple web crawler using Mechanize as a command-line utility. Then I decided to create web app with Sinatra , but got stuck with this error when trying to run the local webserver: /home/nazar/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.2/lib/sinatra/base.rb:1569:in `run!': undefined method `run' for HTTP:Module (NoMethodError) from /home/nazar/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.2/lib/sinatra/main.rb:25:in `block in <module:Sinatra>' The source code is dead simple:

Mechanize & Sinatra conflict

一世执手 提交于 2019-12-23 10:42:10
问题 I've writter a simple web crawler using Mechanize as a command-line utility. Then I decided to create web app with Sinatra , but got stuck with this error when trying to run the local webserver: /home/nazar/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.2/lib/sinatra/base.rb:1569:in `run!': undefined method `run' for HTTP:Module (NoMethodError) from /home/nazar/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.2/lib/sinatra/main.rb:25:in `block in <module:Sinatra>' The source code is dead simple:

node-webkit equivalent for sinatra?

大城市里の小女人 提交于 2019-12-23 10:17:06
问题 I've been thinking about learning how to make simple Mac OS X applications based on web-technology and I came across node-webkit which seems compelling. However, I've recently invested in learning the basics of Sinatra/Ruby and I wanted to stay on that course. Is there a "node-webkit equivalent" for developers who use Sinatra? Or, is there a recommended way to use the Sinatra framework (or Ruby) to build OS X apps that are essentially web wrappers? 回答1: Sinatra is a server-side framework.

Sinatra 1.3 Streaming w/ Ruby stdout redirection

蹲街弑〆低调 提交于 2019-12-23 06:04:20
问题 I would like to use Sinatra's Streaming capability introduced in 1.3 coupled with some stdout redirection. It would basically be a live streaming output of a long running job. I looked into this question and the Sinatra streaming sample in the README. Running 1.8.7 on OSX: require 'stringio' require 'sinatra' $stdout.sync = true module Kernel def capture_stdout out = StringIO.new $stdout = out yield out ensure $stdout = STDOUT end end get '/' do stream do |out| out << "Part one of a three

Sinatra 1.3 Streaming w/ Ruby stdout redirection

一笑奈何 提交于 2019-12-23 06:03:04
问题 I would like to use Sinatra's Streaming capability introduced in 1.3 coupled with some stdout redirection. It would basically be a live streaming output of a long running job. I looked into this question and the Sinatra streaming sample in the README. Running 1.8.7 on OSX: require 'stringio' require 'sinatra' $stdout.sync = true module Kernel def capture_stdout out = StringIO.new $stdout = out yield out ensure $stdout = STDOUT end end get '/' do stream do |out| out << "Part one of a three

Pony yandex.ru and mail.ru specifics

独自空忆成欢 提交于 2019-12-23 02:30:28
问题 I am creating a form in Sinatra that will be sending data to an e-mail on submit using Pony gem. This is my code so far: post '/pemco' do Pony.mail( :from => params[:name] + "<" + params[:email] + ">", :to => '___@yandex.ru', :subject => params[:name] + " has contacted you", :body => params[:message], :via => :smtp, :via_options => { :address => 'smtp.yandex.ru', :port => '465', :enable_starttls_auto => true, :user_name => '___', :password => '___', :authentication => :plain }) redirect '/'

How to map routes to controllers in Sinatra?

对着背影说爱祢 提交于 2019-12-23 02:05:10
问题 I'd like to create a simple experimental MVC framework using Sinatra. I'd like to define resources by name "pages" for example should resolve to: /pages (index) /pages/new /pages/:id/show (show) as WELL as map to app/controllers/PagesController.rb with corresponding get('/') to be responsible for the index, post('/pages/create') be responsible for creation, etc. Trouble is even after reading the official documentation I'm terribly confused. I imagine I need to use non-classic Sinatra model

How to deploy a modular Sinatra app to Heroku?

∥☆過路亽.° 提交于 2019-12-22 17:59:20
问题 For some reason, I can't access any files in the public dir. Not found error. I'm not putting the public part in the URL, obviously. View the Lovers source code repository on GitHub. 回答1: Sweet. I fixed this. After reading about Sinatra Configurations, I added this line to my application class: set :root, Lovers.root That worked! 来源: https://stackoverflow.com/questions/4989711/how-to-deploy-a-modular-sinatra-app-to-heroku

Sinatra: three logs

陌路散爱 提交于 2019-12-22 15:33:33
问题 I'm using a very simple Sinatra app that works well. However, every log message is repeated three times. I can bring that down to two by disabling the Sinatra logging with disable :logging but I still have two. The messages are slightly different, so I gather they are coming from Rack and somewhere else in the stack too. How do I completely disable logging of successful web requests? 回答1: Rack is adding own logging as a middleware try to run rackup -E none This removes one log entry. The