Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'sinatra'
def convert_title_to_filename string
string.gsub(' ','_').downcase + ".md"
end
get '/' do
erb :index
end
post '/' do
file_name = convert_title_to_filename(params[:post_title])
File.open(file_name, 'w') do |f|
f.write params[:post_title]
f.write "\n---\n\n"
f.write params[:post_text]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment