-
-
Save Teut2711/9dde6b3098acceabf5e231776b195d10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IActionResult> OnPostAsync(string opt, string value) | |
{ | |
ProcessStartInfo start = new ProcessStartInfo(); | |
start.FileName = "python/python-3.8.0-embed-amd64/python.exe"; | |
start.Verb = "runas"; | |
start.Arguments = $"python/backend.py {opt} {value}"; | |
start.UseShellExecute = false; | |
start.RedirectStandardOutput = true; | |
using (Process process = Process.Start(start)) | |
{ | |
using (System.IO.StreamReader reader = process.StandardOutput) | |
{ | |
dynamic result = JObject.Parse(reader.ReadToEnd()); | |
var stream = new FileStream(result.path, FileMode.Open); | |
var fileName = "document.pdf"; | |
var mimeType = "application/pdf"; | |
if (result.status == "Success") | |
{ | |
stream = | |
return new FileStreamResult(stream, mimeType) | |
{ | |
FileDownloadName = fileName; | |
}; | |
} | |
else if (result.status == "ErrorDNE") | |
{ | |
} | |
else if (result.status == "ErrorMRE") | |
{ | |
} | |
Console.WriteLine(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment