|
from flask import Flask,request
import json
from CallPowerShell import NewApp,DelApp,GetApp,QueryAllapp
app=Flask(__name__)
@app.route('/newapp', methods=['GET','POST'])
def newapps():
try:
if request.method == 'POST':
jsondata = request.get_data()
dictdata = json.loads(jsondata)
response = NewApp(dictdata["appName"])
return response
else:
mes = '''
<p><h1>Not Found</H1></p>
<p>Request of this path cannot be found, or the server does not exist</p>
'''
return mes
except Exception,error:
print Exception,":",error
@app.route('/delapp', methods=['GET','POST'])
def delapps():
try:
if request.method == 'POST':
jsondata = request.get_data()
dictdata = json.loads(jsondata)
res = DelApp(dictdata['appName'])
return res
else:
mes = '''
<p><h1>Not Found</H1></p>
<p>Request of this path cannot be found, or the server does not exist</p>
'''
return mes
except Exception,error:
print Exception,":",error
@app.route('/getapp')
def getapps():
try:
res = GetApp()
return res
except Exception,error:
print Exception,":",error
@app.route('/queryall')
def queryalls():
try:
res = QueryAllapp()
return res
except Exception,error:
print Exception,":",error
if __name__ == '__main__':
app.run(debug=True,host='0.0.0.0') |
|
|