From 7f43b21d05812da339df25de2190bd0a581c0989 Mon Sep 17 00:00:00 2001 From: NeyoCreator Date: Tue, 3 Sep 2024 20:24:30 -0700 Subject: [PATCH] Added backend capabilities --- .gitignore | 1 + .vscode/settings.json | 5 +++++ app.py | 47 +++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 21 +++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 app.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 6a191b2..7878918 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /venv/ +/env/ /.idea **/__pycache__/ **/.pytest_cache/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..af7446d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.analysis.extraPaths": [ + "./src" + ] +} \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..a27b53f --- /dev/null +++ b/app.py @@ -0,0 +1,47 @@ +from flask import Flask, jsonify, request +import sys +import os +import json + +# Initialize the Flask application +app = Flask(__name__) + +# Get the absolute path of the src directory +src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')) + +import csv +# Add src to the system path +if src_path not in sys.path: + sys.path.append(src_path) + +from jobspy import scrape_jobs + +@app.route('/Recommend_jobs', methods=['GET']) +def get_jobs(): + # Get parameters from the request + site_name = request.args.getlist('site_name') or ["indeed"] + search_term = request.args.get('search_term') or "software engineer" + location = request.args.get('location') or "Dallas, TX" + results_wanted = int(request.args.get('results_wanted', 3)) + hours_old = int(request.args.get('hours_old', 72)) + country_indeed = request.args.get('country_indeed') or 'USA' + + # Scrape the job data + jobs = scrape_jobs( + site_name=site_name, + search_term=search_term, + location=location, + results_wanted=results_wanted, + hours_old=hours_old, + country_indeed=country_indeed + ) + + # Convert jobs to a list of dictionaries + jobs_dict_list = jobs.to_dict(orient='records') + + # Return the JSON response + return jsonify(jobs_dict_list) + +if __name__ == '__main__': + # Run the Flask app + app.run(debug=True) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8561c05 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,21 @@ +annotated-types==0.7.0 +beautifulsoup4==4.12.3 +certifi==2024.8.30 +charset-normalizer==3.3.2 +idna==3.8 +markdownify==0.11.6 +numpy==1.26.3 +pandas==2.2.2 +pydantic==2.8.2 +pydantic_core==2.20.1 +python-dateutil==2.9.0.post0 +python-jobspy==1.1.65 +pytz==2024.1 +regex==2024.7.24 +requests==2.32.3 +six==1.16.0 +soupsieve==2.6 +tls-client==1.0.1 +typing_extensions==4.12.2 +tzdata==2024.1 +urllib3==2.2.2