Michael Schuh | 6ad2469 | 2016-08-24 20:58:31 -0700 | [diff] [blame^] | 1 | require "sinatra" |
| 2 | |
| 3 | # Must use sinatra server for this because fetch() in javascript |
| 4 | # cannot load from the filesystem. |
| 5 | get '/test.html' do |
| 6 | File.read("./test.html") |
| 7 | end |
| 8 | |
| 9 | get '/responsive_plotter.js' do |
| 10 | content_type 'text/javascript' |
| 11 | File.read("./responsive_plotter.js") |
| 12 | end |
| 13 | |
| 14 | get '/test_data' do |
| 15 | content_type 'binary/octet-stream' |
| 16 | data = "" |
| 17 | # Use ./test_data if it exists. Otherwise random data. |
| 18 | if (File.exists?("./test_data")) |
| 19 | data = File.read("./test_data") |
| 20 | else |
| 21 | 1000.times do |
| 22 | data += (1024.times.collect do |i| |
| 23 | (rand() * 480 - 160) |
| 24 | end.pack("F*")) |
| 25 | end |
| 26 | end |
| 27 | data |
| 28 | end |
| 29 | |