-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 lines (32 loc) · 1.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from extractors.reok import extract_reok_jobs
from extractors.wwr import extract_wwr_jobs
from file import save_to_file
from flask import Flask, render_template, request, redirect, send_file
app = Flask("JobScrapper")
@app.route("/")
def home():
return render_template("home.html", name="potato")
db = {}
@app.route("/search")
def search():
keyword = request.args.get("keyword")
if keyword == None:
return redirect("/")
if keyword in db:
jobs = db[keyword]
else:
reok = extract_reok_jobs(keyword)
wwr = extract_wwr_jobs(keyword)
jobs = reok + wwr
db[keyword] = jobs
return render_template("search.html", keyword=keyword, jobs=jobs)
@app.route("/export")
def export():
keyword = request.args.get("keyword")
if keyword == None:
return redirect("/")
if keyword not in db:
return redirect(f"/search?keyword={keyword}")
save_to_file(keyword, db[keyword])
return send_file(f"{keyword}.csv", as_attachment=True)
app.run("127.0.0.1")