webcodelab commited on
Commit
510c4de
·
verified ·
1 Parent(s): 19ccfce

Update app/routes.py

Browse files
Files changed (1) hide show
  1. app/routes.py +11 -13
app/routes.py CHANGED
@@ -439,19 +439,10 @@ def allowed_file(filename):
439
  # "job_description": job_description,
440
  # "ranked_resumes": ranked # List of dicts with filename and score
441
  # })
442
-
443
  @auth.route('/try-api', methods=['GET', 'POST'])
444
  def try_api():
445
- if request.method == 'GET':
446
- return render_template('try_api.html', title="Try the ResumeRanker API")
447
-
448
- # POST logic stays the same
449
- api_key = request.form.get('api_key')
450
- resumes = request.files.getlist('resumes')
451
- job_description = request.form.get('job_description')
452
-
453
  if 'user_id' not in session:
454
- flash('Please log in to Test the API.')
455
  return redirect(url_for('auth.login'))
456
 
457
  user_id = session['user_id']
@@ -465,7 +456,15 @@ def try_api():
465
  flash('User not found.')
466
  return redirect(url_for('auth.login'))
467
  user = user_res.json()[0]
468
-
 
 
 
 
 
 
 
 
469
  if not api_key:
470
  flash("API key is required.")
471
  return redirect(url_for('auth.try_api'))
@@ -497,14 +496,13 @@ def try_api():
497
  flash(f"Error processing resumes: {str(e)}")
498
  return redirect(url_for('auth.try_api'))
499
 
500
- return render_template('try_api.html', response={
501
  "job_description": job_description,
502
  "ranked_resumes": ranked
503
  })
504
 
505
 
506
 
507
-
508
  @auth.route('/ping-db')
509
  def ping_db():
510
  try:
 
439
  # "job_description": job_description,
440
  # "ranked_resumes": ranked # List of dicts with filename and score
441
  # })
 
442
  @auth.route('/try-api', methods=['GET', 'POST'])
443
  def try_api():
 
 
 
 
 
 
 
 
444
  if 'user_id' not in session:
445
+ flash('Please log in to test the API.')
446
  return redirect(url_for('auth.login'))
447
 
448
  user_id = session['user_id']
 
456
  flash('User not found.')
457
  return redirect(url_for('auth.login'))
458
  user = user_res.json()[0]
459
+
460
+ if request.method == 'GET':
461
+ return render_template('try_api.html', title="Try the ResumeRanker API", user=user)
462
+
463
+ # POST logic
464
+ api_key = request.form.get('api_key')
465
+ resumes = request.files.getlist('resumes')
466
+ job_description = request.form.get('job_description')
467
+
468
  if not api_key:
469
  flash("API key is required.")
470
  return redirect(url_for('auth.try_api'))
 
496
  flash(f"Error processing resumes: {str(e)}")
497
  return redirect(url_for('auth.try_api'))
498
 
499
+ return render_template('try_api.html', user=user, response={
500
  "job_description": job_description,
501
  "ranked_resumes": ranked
502
  })
503
 
504
 
505
 
 
506
  @auth.route('/ping-db')
507
  def ping_db():
508
  try: