=begin ########PERL 5 CODE########### #use warnings; #use strict; #use HTTP::Server::Simple; #my $server = HTTP::Server::Simple->new(); #$server->run(); ############################## =end =begin Before you fully understand this, you ought to learn Perl, at least a little, but I will try to help in every way, shape, and form. =end require 'sinatra' =begin THIS PART OF THE SCRIPT WORKS FINE ON ITS OWN. $accumulator=0 #words=IO.readlines("numerology_chase.txt") words=open("code.txt",&:read).split("") #File.open("numerology_chase.txt").each_line do |line| for i in words $accumulator += i.to_i end accumulator_data = $accumulator.to_s numerology=accumulator_data.split("") $i=0 for i in numerology $i+=i.to_i end puts "And the number is: #{$i}" =end before do #do this before anything happens, just to be certain content_type :text require 'mechanize' end #for require 'mechanize' def numerology(url) #mechanize has the capability of logging into websites, #data mining, among other things, especially downloading using "read=agent.get(url)" agent=Mechanize.new read = agent.get(url) save_as = read.save_as("webpage_#{Random.rand(0..(10**100+10*100)).to_s}_.html") #save this as a random webpage return save_as #everyone will understand this, but you don't even need to return anything, all you need in a single line is "save_as" end #$page_counter=0 get '/url_num/*' do a=numerology("#{params[:splat].shift}".sub!(/\//,'//')) #convert the wrong url back into http:// from http:/, #as far as I can remember. file_name=a $accumulator=0 #global variable words=open("#{file_name}",&:read).split("") #open, read, then split the downloaded file into individual bytes for i in words $accumulator += i.to_i #add up all the char bytes; ascii==numbers end accumulator_data = $accumulator.to_s #convert to string numerology=accumulator_data.split("") $i=0 for i in numerology $i+=i.to_i end "And the number is: #{$i}" #numerology_proc=$agent.get("#{params[:splat]}") #"You passed in #{numerology_proc.inner_html}" end =begin {loading spaghetti code} set :views, File.dirname(__FILE__) + '/public' #set views to ./html (current directory/html) def load_pictures Dir.glob("#{File.dirname(__FILE__)}/*.{jpg,JPG,gif,GIF,PNG}") end get '/' do @pictures = load_pictures erb :index end =end