Created
June 22, 2013 02:20
-
-
Save STRd6/5835574 to your computer and use it in GitHub Desktop.
Save data to your local filesystem by posting to your webserver.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra" | |
configure do | |
set :root, "." | |
set :public_folder, "." | |
end | |
# Any post to /save will write data to the path provided. | |
post '/save' do | |
data = params["data"] | |
path = params["path"] | |
# Ensure directory exists | |
FileUtils.mkdir_p File.dirname(path) | |
File.open(path, 'w') do |file| | |
file.write(data) | |
end | |
200 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment