Skip to content

Commit cdb21f5

Browse files
committed
.env example created, views file updated with latest API with dummy URLs requirements updated with new package
1 parent cff6071 commit cdb21f5

File tree

7 files changed

+67
-98
lines changed

7 files changed

+67
-98
lines changed

.DS_Store

8 KB
Binary file not shown.

.env.EXAMPLE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RAPIDAPI_KEY=""
2+
SECRET_KEY=""

README.md renamed to RoadMap.md

File renamed without changes.

crawl/views.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,59 @@
1+
import random
2+
import requests
13
from django.shortcuts import render
2-
from django.http import HttpResponse
4+
from django.http import HttpResponse, JsonResponse
5+
from decouple import config
6+
7+
RAPIDAPI_KEY = config.get("RAPIDAPI_KEY", "")
8+
RAPIDAPI_HOST = "jobs-api14.p.rapidapi.com"
9+
BASE_URL = f"https://{RAPIDAPI_HOST}/v2/list"
310

411
def index(request):
512
return HttpResponse("Hello, this is the crawl app index page.")
613

14+
def fetch_jobs(request):
15+
# Get query parameters from Django request
16+
keyword = request.GET.get("keyword", "Web Developer")
17+
location = request.GET.get("location", "United States")
18+
remote_only = request.GET.get("remoteOnly", "false") # Default: false
19+
employment_types = request.GET.get("employmentTypes", "fulltime;parttime;intern;contractor") # Default values
20+
21+
22+
# Construct query parameters
23+
params = {
24+
"query": keyword,
25+
"location": location,
26+
"autoTranslateLocation": "true",
27+
"remoteOnly": remote_only,
28+
"employmentTypes": "fulltime;parttime;intern;contractor"
29+
}
30+
31+
# Set request headers
32+
headers = {
33+
"x-rapidapi-host": RAPIDAPI_HOST,
34+
"x-rapidapi-key": RAPIDAPI_KEY
35+
}
36+
37+
try:
38+
# Make the API request
39+
response = requests.get(BASE_URL, headers=headers, params=params)
40+
41+
# Handle response
42+
if response.status_code == 200:
43+
return JsonResponse(response.json(), safe=False)
44+
else:
45+
return JsonResponse({"error": "Failed to fetch jobs", "status_code": response.status_code}, status=500)
46+
47+
except requests.RequestException as e:
48+
return JsonResponse({"error": str(e)}, status=500)
49+
50+
def privacy_policy(request):
51+
"""hastily made privacy policy for chatgpt
52+
53+
Args:
54+
request (_type_): _description_
55+
56+
Returns:
57+
_type_: _description_
58+
"""
59+
return render(request, "privacy_policy.html")

elia/settings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
from pathlib import Path
14+
from decouple import config
1415

1516
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1617
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -20,15 +21,13 @@
2021
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
2122

2223
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = 'django-insecure-%ywl#7v=4$nc*ajp4tmvbf^re1%3z*qh=brp@5zfa*f!*_=m(c'
24+
SECRET_KEY = config("SECRET_KEY", None)
2425

2526
# SECURITY WARNING: don't run with debug turned on in production!
2627
DEBUG = True
2728

2829
ALLOWED_HOSTS = [
2930
'127.0.0.1', 'localhost', '0.0.0.0',
30-
'elia-project-453221.lm.r.appspot.com',
31-
3231
]
3332

3433

fetch-jobs-v1.0.0.schema

Lines changed: 0 additions & 94 deletions
This file was deleted.

requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
asgiref==3.8.1
2+
beautifulsoup4==4.13.3
23
CacheControl==0.14.2
34
cachetools==5.5.2
45
certifi==2025.1.31
@@ -24,7 +25,9 @@ gunicorn==23.0.0
2425
httplib2==0.22.0
2526
idna==3.10
2627
msgpack==1.1.0
28+
numpy==2.2.3
2729
packaging==24.2
30+
pandas==2.2.3
2831
proto-plus==1.26.0
2932
protobuf==5.29.3
3033
pyasn1==0.6.1
@@ -33,9 +36,15 @@ pycparser==2.22
3336
PyJWT==2.10.1
3437
pyparsing==3.2.1
3538
PySocks==1.7.1
39+
python-dateutil==2.9.0.post0
40+
python-decouple==3.8
41+
pytz==2025.1
3642
requests==2.32.3
3743
rsa==4.9
3844
six==1.17.0
45+
soupsieve==2.6
3946
sqlparse==0.5.3
47+
typing_extensions==4.12.2
48+
tzdata==2025.1
4049
uritemplate==4.1.1
4150
urllib3==2.3.0

0 commit comments

Comments
 (0)