-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |