khurrameycon commited on
Commit
d228bc3
·
verified ·
1 Parent(s): 5383f36

if Syllabi URL is null .. case handled

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -286,15 +286,18 @@ def favicon():
286
  @app.route("/extract", methods=["POST"])
287
  def extract_info():
288
  data = request.json
289
- if not data or "url" not in data:
290
  return jsonify({"error": "Please provide a PDF URL in the request body."}), 400
291
 
292
- pdf_url = data["url"]
293
  try:
294
- pdf_text = extract_text_from_pdf(pdf_url)
295
- prompt = f"{PROMPT}\n\n{pdf_text}"
296
- response = predict_text(prompt)
297
-
 
 
 
 
298
  if data["skills"] == True:
299
  prompt_skills = f"{PROMPT_SKILLS} using this information only -- {response}"
300
  response_skills = predict_text(prompt_skills)
 
286
  @app.route("/extract", methods=["POST"])
287
  def extract_info():
288
  data = request.json
289
+ if not data:
290
  return jsonify({"error": "Please provide a PDF URL in the request body."}), 400
291
 
 
292
  try:
293
+ if data["url"] is not None:
294
+ pdf_url = data["url"]
295
+ pdf_text = extract_text_from_pdf(pdf_url)
296
+ prompt = f"{PROMPT}\n\n{pdf_text}"
297
+ response = predict_text(prompt)
298
+ else:
299
+ response = ''
300
+
301
  if data["skills"] == True:
302
  prompt_skills = f"{PROMPT_SKILLS} using this information only -- {response}"
303
  response_skills = predict_text(prompt_skills)