-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
54 lines (44 loc) · 1.21 KB
/
server.py
File metadata and controls
54 lines (44 loc) · 1.21 KB
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
47
48
49
50
51
52
53
54
from flask import Flask, render_template, request, redirect, send_file
from indeedScrapper import give_me_job
from exporter import save_to_file
import datetime
t = datetime.datetime.now()
y = t.year
m = t.month
d = t.day
date = str(y)+'-'+str(m)+'-'+str(d)
app = Flask("BugBug")
fakeDB = {}
@app.route("/")
def home():
return render_template('home2.html')
@app.route("/report")
def report():
render_template('loading.html')
word = request.args.get('word').strip()
if word != '':
word = word.capitalize()
jobExist = fakeDB.get(word)
if jobExist:
jobs = jobExist
else:
jobs = give_me_job(word)
fakeDB[word] = jobs
else:
return redirect('/')
return render_template('report2.html', keyword=word, jobs=jobs, resultNum=len(jobs))
@app.route("/export")
def export():
try:
word = request.args.get('word')
if not word:
raise Exception()
word = word.capitalize()
jobs = fakeDB.get(word)
if not jobs:
raise Exception()
save_to_file(jobs,word)
return send_file("jobs.csv", mimetype = 'text/csv; charset=x-EBCDIC-KoreanAndKoreanExtended')
except:
return redirect("/")
app.run(host='0.0.0.0')