This commit is contained in:
2025-05-21 19:13:17 +05:30
parent 6f340990e9
commit f53919a3cd
4 changed files with 371 additions and 29 deletions

23
apps/PdfService/main.py Normal file
View File

@@ -0,0 +1,23 @@
from flask import Flask, request, jsonify
import fitz # PyMuPDF
import re
app = Flask(__name__)
@app.route("/extract", methods=["POST"])
def extract():
file = request.files['pdf']
doc = fitz.open(stream=file.read(), filetype="pdf")
text = "".join(page.get_text() for page in doc)
name = re.search(r"Name:\s*(.*)", text)
email = re.search(r"Email:\s*(.*)", text)
return jsonify({
"text": text,
"name": name.group(1).strip() if name else "",
"email": email.group(1).strip() if email else ""
})
if __name__ == "__main__":
app.run(port=5001)