77 lines
1.9 KiB
Python
77 lines
1.9 KiB
Python
|
|
from flask import Flask, request, send_file
|
|
from flask_restful import Api
|
|
from flask.views import MethodView
|
|
|
|
from HWPToPDF import converHWPtoPDF
|
|
from PDFToJPG import converPDFToJPG
|
|
from reqeustFile import RequestFileSave
|
|
|
|
from werkzeug.utils import secure_filename
|
|
|
|
from urllib import parse
|
|
|
|
import os
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
app.config['JSON_AS_ASCII'] = False
|
|
|
|
api = Api(app)
|
|
|
|
|
|
class processingHWPtoPDF(MethodView):
|
|
def post(self):
|
|
|
|
if 'file' not in request.files:
|
|
return 'No file part in the request', 400
|
|
|
|
file = request.files['file']
|
|
|
|
print(f'fileNm {file.filename}')
|
|
step1 = RequestFileSave.RequestFileSave(file)
|
|
print(f'step1 {step1}')
|
|
return send_file(converHWPtoPDF.HWPtoPDF(step1), mimetype="multipart/form-data", as_attachment=True)
|
|
|
|
|
|
class processingHWPtoJPG(MethodView):
|
|
def post(self):
|
|
|
|
fileNm = request.form['fileNm']
|
|
print(f'fileNm {fileNm}')
|
|
|
|
converPDFToJPG.PDFToJPG(converHWPtoPDF.HWPtoPDF(fileNm))
|
|
|
|
return 'hello'
|
|
|
|
class testSendFile(MethodView):
|
|
def get(self):
|
|
# data = request.form['testPath']
|
|
# returnData = data.get('testPath')
|
|
|
|
filePath = "E:/pdf/test.pdf"
|
|
|
|
return send_file(filePath, mimetype="Content-Type: multipart/form-data; charset=UTF-8", as_attachment=True)
|
|
|
|
# class RequestFile(MethodView):
|
|
# def post(self):
|
|
# RequestFileSave.RequestFileSave(request.files['file'])
|
|
|
|
# return ''
|
|
|
|
|
|
@app.route('/')
|
|
def hello_world(): # put application's code here
|
|
return 'Hello World!'
|
|
|
|
|
|
api.add_resource(processingHWPtoPDF, '/converHWPtoPDF')
|
|
api.add_resource(processingHWPtoJPG, '/converHWPtoJPG')
|
|
api.add_resource(testSendFile, '/testSendFile')
|
|
# api.add_resource(RequestFile, '/testRequestFile')
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0')
|
|
# app.run(host='192.168.0.11')
|