I would simply like to display a .txt file located in my public directory onto a page. I apologise that this may seem novice but I am new to Ruby.
So far the ruby sinatra code reads:
get '/create' do
logfile = File.open("logfile.txt")
erb :create
end
and the erb reads:
<h2>Text file:</h2>
<%= logfile %>
Can someone tell me what I need to display this text file on my page?
Another way to show .txt file with Sinatra(without erb).
in your script:
get '/' do
send_file 'views/file.txt'
end
puts file.txt with content:
Heloo ! somebody here?

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With