I am pretty new to python as I've been using PHP in the past. I am trying to practice python by converting my PHP code to python. I have the following php code to receive POST data from webserver and make a call over ssh to output a text file of a remote server back to the page.
app.js:
$(document).ready(function(){
$("button").on('click', function() {
//call python script to generate report
$.get("/", function(data){
$( "#statusOutput" ).val(data);
});
});
});
gettextoutput.php:
<?php //gettextoutput.php
$user = 'user';
$password = 'pass';
$path = '/path/to/my/text/file';
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$hostname = $_POST['hostname']; //10.139.x.x
$textoutput = file_get_contents("ftp://$user:$password@$hostname/$path");
echo $textoutput; // I can use this to display the text output back to the page
}
?>
I was wondering if there is a way to do this in python as well? Any information would be appreciated!