forked from MMaues/api_excel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
31 lines (22 loc) · 905 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
import pandas as pd
from flask import Flask, request, Response
from flask_restful import Resource, Api
from src.editorExcel import EditarExcel
import zipfile
import pathlib
app = Flask(__name__)
api = Api(app)
class app_main(Resource):
@app.route("/v1/api/modificadorexcel", methods=["POST"])
def modificar_excel(*self):
response_excel: bytes = request.files["excel_notas"]
notas_df: pd.DataFrame = pd.read_excel(response_excel)
directory = pathlib.Path("files/")
classe = EditarExcel()
excel = classe.main(notas_df)
with zipfile.ZipFile("notas.zip", mode="w") as archive:
for file_path in directory.iterdir():
archive.write(file_path, arcname=file_path.name)
return Response(excel, 200)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=2000)