<commit_before><?php


require("vendor/slim/slim/Slim/Slim.php");
require("Database.php");
\Slim\Slim::registerAutoloader();
define('PATH', $_SERVER['SERVER_NAME']);

$app = new \Slim\Slim();

// Returns the status of the current job.
$app->get('/api/v1/jobs/:id', function($id) use($app){
	DB::FindJob($id);
});

// Show a list of running and completed tasks.
$app->get('/api/v1/list/', function() use($app){
	// Grab the list of files.
	//$db->ListJobs();
	DB::ListJobs();
	// Display the list.
});

// Download the finished project.
$app->get('/api/v1/download/:id', function($id) use($app){
	print $id;
	// Retrieve the file and start the download.
});

// Upload the file to the server and return the job ID.
$app->post('/api/v1/jobs/', function() use($app){
	$ext = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
	if($_FILES["file"]["type"] != "application/octet-stream" ||
	   $ext != "fds"){
		echo "You have uploaded an invalid file.";
	}else{
		echo "Your file is now being uploaded to the server.";
		$target = "uploads/" . basename( $_FILES["file"]["name"]);
		if(move_uploaded_file($_FILES["file"]["tmp_name"], $target)){
			echo "The file " . basename($_FILES["file"]["name"]) . " has been uploaded.";
		}
		// Upload to the database here.

		DB::AddJob(basename($_FILES["file"]["name"]));
	}
});

// Run the code.
$app->run();<commit_msg>Tidied up how POST jobs handles displaying messages for uploaded files.<commit_after><?php


require("vendor/slim/slim/Slim/Slim.php");
require("Database.php");
\Slim\Slim::registerAutoloader();
define('PATH', $_SERVER['SERVER_NAME']);

$app = new \Slim\Slim();

// Returns the status of the current job.
$app->get('/api/v1/jobs/:id', function($id) use($app){
	DB::FindJob($id);
});

// Show a list of running and completed tasks.
$app->get('/api/v1/list/', function() use($app){
	// Grab the list of files.
	//$db->ListJobs();
	DB::ListJobs();
	// Display the list.
});

// Download the finished project.
$app->get('/api/v1/download/:id', function($id) use($app){
	print $id;
	// Retrieve the file and start the download.
});

// Upload the file to the server and return the job ID.
$app->post('/api/v1/jobs/', function() use($app){
	$ext = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
	if($_FILES["file"]["type"] != "application/octet-stream" ||
	   $ext != "fds"){
		echo "You have uploaded an invalid file.";
	}else{
		$target = "uploads/" . basename( $_FILES["file"]["name"]);
		if(move_uploaded_file($_FILES["file"]["tmp_name"], $target)){
			echo "The file " . basename($_FILES["file"]["name"]) . " has been uploaded.<br />";
		}else{
			echo "There was an error trying to upload the file. Please try again.";
		}
		
		// Upload to the database here.
		DB::AddJob(basename($_FILES["file"]["name"]));
	}
});

// Run the code.
$app->run();
{'fraction_non_alphanumeric': 0.2191829484902309, 'fraction_numerical': 0.002841918294849023, 'mean_word_length': 4.273408239700374, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5458549', 'n_tokens_mistral': 1019, 'n_tokens_neox': 990, 'n_words': 251}