我想從ruby腳本上傳圖像到運行Sinatra的服務器,對於我的生活我無法弄清楚。 這是我到目前爲止。 服務器: post '/uploads/:filename' do
File.open("./uploads/#{params[:filename]}", 'wb') do |f|
f.write(params[:filename].read)
end
end
我不明白,爲什麼在條件不工作, 我想執行的一部分,如果用戶名和密碼都爲空 post '/login' do
credentials = CGI.parse request.body.read
if credentials['username'].nil? || credentials['password'].nil?
status 603
return