From 669ce7abd7d6b632bf1844afdb2cf0b28e1efed6 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Wed, 22 Jun 2016 07:04:12 +0200 Subject: faster, better, stronger --- file_upload.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'file_upload.rb') diff --git a/file_upload.rb b/file_upload.rb index 5bb1d44..0599ef3 100644 --- a/file_upload.rb +++ b/file_upload.rb @@ -1,4 +1,4 @@ -require 'sinatra/base' +require 'sinatra' require 'haml' class FileUpload < Sinatra::Base @@ -6,6 +6,9 @@ class FileUpload < Sinatra::Base enable :static enable :sessions + #set :bind, 'upload.simianer.de' + set :port, 8000 + set :environment, :production set :views, File.join(File.dirname(__FILE__), 'views') set :public_folder, File.join(File.dirname(__FILE__), 'public') end @@ -30,12 +33,12 @@ class FileUpload < Sinatra::Base saved_token = `cat #{dir}/.token`.strip if token == saved_token return true - end + end return false end def check_dirname dirname - return dirname.match /^[a-zA-Z0-9_-]+$/ + return dirname.match /^[a-zA-Z0-9_]+$/ end def get_dir dirname @@ -101,7 +104,7 @@ class FileUpload < Sinatra::Base get "/list_dir/:dirname/:token" do log '/list_dir', params - + dirname = params[:dirname] dir = get_dir dirname token = params[:token] @@ -110,7 +113,7 @@ class FileUpload < Sinatra::Base if allowed s = "