修订ANSWER: 我绑所有上述没有运气被ablle的加载CSS,JS .. ..等内容唯一加载的是index.html ...其余的都是= >>404 error
我的解决方案:应用程序文件夹看起来像这样。
index.rb
== >>西纳特拉代码去。
require 'rubygems'
require 'sinatra'
get '/' do
html :index
end
def html(view)
File.read(File.join('public', "#{view.to_s}.html"))
end
public folder
== >>包含一切...... CSS,JS,等等blah..etc。
[email protected]:~/sintra1$ ls
index.rb public
[email protected]:~/sintra1$ find public/
public/
public/index.html
public/about_us.html
public/contact.html
public/fonts
public/fonts/fontawesome-webfont.svg
public/fonts/fontawesome-webfont.ttf
public/img
public/img/drink_ZIDO.jpg
public/js
public/js/bootstrap.min.js
public/js/jquery.min.js
public/js/bootstrap.js
public/carsoul2.html
public/css
public/css/font-awesome-ie7.css
public/css/bootstrap.min.css
public/css/font-awesome.min.css
public/css/bootstrap.css
public/css/font-awesome.css
public/css/style.css
[email protected]:~/sintra1$
现在启动服务器,您将能够浏览静态页面,没有问题。
[email protected]:~/sintra1$ ruby index.rb
== Sinatra/1.4.5 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:4567, CTRL+C to stop
来源
2015-01-27 22:10:44
zee
我了解到访问http:// localhost:2345/index.html的作品。 – 2010-03-20 11:11:22
您可以使用WebBrick在几行中提供静态文件。 '需要'webrick'; server = WEBrick :: HTTPServer.new Port:1234;服务器。mount'/',WEBrick :: HTTPServlet :: FileHandler,'www /';陷阱(“INT”){server.stop}; server.start;'然后运行'ruby myapp.rb'。删除Heroku的端口。把'web:ruby myapp.rb'放到你的'Procfile'中。评论没有回答,因为它不是Sinatra,但我认为它简化了依赖关系。 – Chloe 2016-01-16 07:09:36