I've been working on this Python script that creates an excel file, but I wanted to be able to distribute the script by creating a website that can run the script and download the file.
<a href="file:shift.xlsx" target="_blank">
<h3>Download Schedule</h3>
</a>
<input type="button" id='script' name="scriptbutton" value=" Run Script " onclick="goPython()">
<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
function goPython() {
$.ajax({
alert("Check"),
type: "POST",
url: "main.py",
}).done(function(o) {
alert("Complete")
});
}
</script>
The python code is as follows:
import xlsxwriter
workbook = xlsxwriter.Workbook('shift.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write(0,0, "test")
workbook.close()
When I try to download the file it says that it can't be found. Is it possible to do this without Django or Flask? Thanks!