Skip to content

Commit

Permalink
Create app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
5uperfred authored Sep 24, 2024
1 parent 03c6949 commit 76ffebe
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions DataXtractor-1.0.7/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from flask import Flask, request, jsonify
from DataXtractor import DataXtractor
import base64
import io

app = Flask(__name__)
extractor = DataXtractor()

@app.route('/extract', methods=['POST'])
def extract_data():
if 'file' not in request.files:
return jsonify({'error': 'No file part in the request'}), 400
file = request.files['file']
if file.filename == '':
return jsonify({'error': 'No file selected for uploading'}), 400

# Read the file
file_bytes = file.read()
file_obj = io.BytesIO(file_bytes)

# Extract data
result = extractor.extract(file_obj)

return jsonify(result)

if __name__ == '__main__':
app.run(host='0.0.0.0', port=10000)

0 comments on commit 76ffebe

Please sign in to comment.