Я хочу запустить сценарий Powershell, который использует вводимые пользователем данные через html-страницу.
Но он никогда не достигает сценария Powershell.
Итак, в функции cqforward сценарий Powershell работает нормально. Как во второй функции cqshowlist веб-приложение не достигает сценария Powerschell после того, как я заполняю поле ввода и нажимаю кнопку?
Код: Выделить всё
from flask import Flask, render_template, request, jsonify
import subprocess
import json
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/Activate Forward',methods=['GET','POST'])
def cqforward():
if request.method == 'POST':
namecq = request.form.get('namecq')
phonenumber = request.form.get('phonenumber')
subprocess.run(["powershell","-File","cqforward.ps1", namecq, phonenumber])
data = {
'namecq': namecq,
'phonenumber' : phonenumber
}
return render_template('cqforward.html', data = {"namecq": namecq, "phonenumber": phonenumber})
return render_template('cqforward.html', data = None)
@app.route('/Show list',methods=['GET','POST'])
def cqshowlist():
if request.method == 'POST':
listcqname = request.form.get('listcqname')
subprocess.run(["powershell","-File","listofcallqueues.ps1", listcqname])
data = {
'listcqname': listcqname
}
return render_template('cqshowlist.html', data = {"listcqname": listcqname})
return render_template('cqshowlist.html', data = None)
@app.route('/Show Holidays')
def holidays():
return render_template('tgholidays.html')
if __name__ == '__main__':
app.run(debug=True)
И ниже — сценарий Powershell:
Код: Выделить всё
param(
[string]$listcqname
)
$listnamecqVariable = "CQ-"+ $listcqname + "-*"
Write-Output "Name: $listnamecqVariable"
Connect-MicrosoftTeams
#Get all Call Queues via the CQ-FSECO Security groups
$CallQueues = Get-CsCallQueue -NameFilter {Name -Like $listnamecqVariable}
#Set the csv-file
$Directory = "test.csv"
$DirectoryXlsx = "Test.xlsx"
Set-Content -Path $Directory -Value "Name"
#Go Through the Call queues list
foreach($CQs in $CallQueues)
{
$Name = $CQs.Name
$Name
Add-Content -Path $Directory -Value "$Name"
}
import-Csv -Path $Directory | Export-Excel -Path $DirectoryXlsx -WorksheetName "Sheet1" -AutoSize -BoldTopRow
#import-csv -Path $Directory |Export-Excel -Path $DirectoryXlsx
Write-Output "Finished Running"
Печать экрана страницы веб-приложения
Подробнее здесь: https://stackoverflow.com/questions/787 ... ell-script