123456789101112131415161718192021222324252627282930313233343536 |
- from flask import Flask, request, Response, jsonify, send_file
- from data_employee import DataEmployee
- from xlsx_creator import xlsx_creator
- import json
- app = Flask(__name__)
- @app.after_request
- def after_request(response):
- response.headers.add('Access-Control-Allow-Origin', '*')
- response.headers.add('Access-Control-Allow-Headers',
- 'Content-Type,Authorization')
- response.headers.add('Access-Control-Allow-Methods',
- 'GET,PUT,POST,DELETE,OPTIONS')
- return response
- @app.route('/get_data', methods=['POST'])
- def get_data():
- FIOS = request.values['fios'].split(',')
- STARTDATE = request.values['startDate']
- ENDDATE = request.values['endDate']
- DATA = DataEmployee(FIOS, STARTDATE, ENDDATE)
- return jsonify(DATA.get_json())
- @app.route('/get_xlsx_file', methods=['POST'])
- def get_xlsx_file():
- xlsx = xlsx_creator(json.loads(request.data))
- return send_file(xlsx.cook_xlsx(), as_attachment=xlsx.FileName)
- if __name__ == "__main__":
- app.run(host='0.0.0.0')
|