-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
32 lines (26 loc) · 981 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask, abort, request, url_for, redirect, jsonify, Blueprint
from vmware_api import vms
# import vmware_automate
from config import SECRET_KEY
app = Flask(__name__)
app.config['SECRET_KEY'] = SECRET_KEY
app.register_blueprint(vms)
# app.config['vmware'] = vmware_automate.setup()
@app.route('/')
def index():
return jsonify({'connected': str(app.config.get('vmware', {}).get('esxi', {}).get('host'))})
@app.route('/upload', methods=['POST'])
def upload():
res = {}
if request.files is None:
res['status'] = 'Error! No files found in uploaded data!'
else:
res['files'] = []
for filename in request.files:
print(filename)
request.files[filename].save(filename)
res['files'].append(filename)
res['status'] = 'Successfully downloaded {} files: {}'.format(len(res['files']), res['files'])
return jsonify(res)
if __name__ == '__main__':
app.run(debug=True, port='5001')