我是初学者,按照here发现的说明操作,并设法让“sweet_dashboard_project”成功运行。
在仪表板底部显示:
"Try this: curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "Hey, Look what I can do!" }' \http://localhost:3030/widgets/welcome"
当我尝试时,会发生以下错误:
curl: (6) Could not resolve host: auth_token
curl: (6) Could not resolve host: YOUR_AUTH_TOKEN,
curl: (6) Could not resolve host: text
curl: (6) Could not resolve host: Hey, Look what I can do!
curl: (3) [globbing] unmatched close brace/bracket in column 1
curl: (1) Protocol \http not supported or disabled in libcurl
config.ru看起来像这样
require 'dashing'
configure do
set :auth_token, 'YOUR_AUTH_TOKEN'
helpers do
def protected!
# Put any authentication code you want in here.
# This method is run before accessing any resource.
end
end
end
map Sinatra::Application.assets_prefix do
run Sinatra::Application.sprockets
end
run Sinatra::Application
我在这里做错了什么?
谢谢!
答案 0 :(得分:2)
您使用的\http
不正确。
另外,在json周围放置双引号(如果你使用windows)。使用标题application/json
。
curl -d "{ \"auth_token\": \"YOUR_AUTH_TOKEN\", \"text\": \"Hey, Look what I can do!\" }' -H "Content-Type: application/json" http://localhost:3030/widgets/welcome
答案 1 :(得分:1)
假设您使用的是Windows,这将有效吗?
curl -X POST -H "Content-Type: application/json" -d "{ \"auth_token\": \"YOUR_AUTH_TOKEN\", \"text\": \"Hey, Look what I can do!\" }" http://localhost:3030/widgets/welcome