我正在尝试创建一个简单的脚本来返回进程的状态。终点正在起作用,请求也是如此,错误如下:
AttributeError: 'str' object has no attribute 'get'
import subprocess
import sys
import json
from flask import Flask, json
processDefender=subprocess.Popen(["powershell","get-process | Select-string lsass"], stdout=subprocess.PIPE, shell=False)
resultDef = processDefender.communicate()[0].decode('utf-8').strip()
dataPw = {}
dataPw['Defender'] = resultDef
dataFn = json.dumps(dataPw, sort_keys=True, indent=4)
print(dataFn)
import os
import json
import requests
import subprocess
from powershell import *
from DetectOS import *
r = requests.post('http://127.0.0.1:5000/connection', json=dataFn, headers={'Content-type': 'application/json', 'Accept': 'text/plain'})
@app.route('/connection', methods=['POST'])
def result():
mydata = request.json # will be
print(mydata)
return jsonify({'message' : '1!'})