-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.py
64 lines (49 loc) · 1.76 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from flask import Flask, request, render_template
from resourcer import resourcer
app = Flask(__name__)
CATEGORIES = {
"Python": "python",
"JavaScript": "javascript",
"C++": "cpp",
"C":"c",
"CSS":"css",
"Data Structures & Algorithms": "dsa",
"Machine Learning": "machine-learning",
"Deep Learning": "deep-learning",
"Computer Science": "computer-science",
"Computer Graphics": "computer-graphics",
"Git": "git",
"Android": "android",
"Surprise Me!": "miscellaneous",
}
@app.route("/", methods=["GET"])
def home():
return render_template("categories.html", categories=CATEGORIES)
@app.route("/resources", methods=["GET"])
def category():
category = request.args.get("category")
rsr = resourcer.Resource(category)
resources = rsr.get_resource()
return render_template(
"resources.html", resources=resources["resources"], category=category
)
@app.route("/contributors", methods=["GET"])
def contributors():
contributors = resourcer.Resource.get_all_contributors()
return render_template(
"contributors.html", contributors=contributors["contributors"]
)
@app.route("/filtered_resources", methods=["POST"])
def filtered_resources():
res_type = request.form.get("type")
res_level = request.form.get("level")
rsr = resourcer.Resource(request.form.get("category"))
if res_level is not None:
resources = rsr.get_resources_by_level(res_level)
return render_template("filtered_resources.html", resources=resources)
elif res_type is not None:
resources = rsr.get_resources_by_type(res_type)
return render_template("filtered_resources.html", resources=resources)
return "Wuba luba dub dub"
if __name__ == "__main__":
app.run(debug=True)