1
1
# SPDX-FileCopyrightText: 2023 Alec Delaney
2
2
# SPDX-License-Identifier: MIT
3
3
4
- """
5
- Main entry point for the flask application
4
+ """Main entry point for the flask application.
6
5
7
6
Author: Alec Delaney
8
7
"""
51
50
52
51
@app .route ("/" )
53
52
def index () -> str :
54
- """Route for index (landing page)"""
53
+ """Route for index (landing page). """
55
54
return render_template ("index.html" )
56
55
57
56
58
57
@app .route ("/set-menorah" )
59
58
def menorah_settings () -> Response :
60
- """Route for shortcut to menorah settings page"""
59
+ """Route for shortcut to menorah settings page. """
61
60
return redirect ("/projects/menorah/settings" )
62
61
63
62
64
63
@app .route ("/projects/menorah/settings" , methods = ["GET" , "POST" ])
65
64
@limiter .limit ("10/second" , key_func = lambda : "menorah-settings" )
66
65
def project_menorah_settings () -> str :
67
- """Route for creating menorah settings file"""
66
+ """Route for creating menorah settings file. """
68
67
input_form = MenorahSetupForm ()
69
68
if input_form .validate_on_submit ():
70
69
zipcode = input_form .data ["zipcode" ]
71
- with open ("assets/settings.json" , mode = "r" , encoding = "utf-8" ) as template_file :
70
+ with open ("assets/settings.json" , encoding = "utf-8" ) as template_file :
72
71
template_text = template_file .read ()
73
72
template = jinja2 .Template (template_text )
74
73
rendered_temp = template .render (zipcode = zipcode )
@@ -83,7 +82,7 @@ def project_menorah_settings() -> str:
83
82
84
83
@app .route ("/recent" , methods = ["GET" ])
85
84
def recent () -> str :
86
- """Route for recent GitHub activity"""
85
+ """Route for recent GitHub activity. """
87
86
with open ("assets/contrib/recent.json" , encoding = "utf-8" ) as respfile :
88
87
contents = json .load (respfile )
89
88
contributions , repos = contents ["contributionsCollection" ], contents ["repositories" ]
@@ -104,11 +103,11 @@ def recent() -> str:
104
103
105
104
@app .route ("/about" , methods = ["GET" ])
106
105
def about () -> str :
107
- """Route for about me page"""
106
+ """Route for about me page. """
108
107
jobs_path = pathlib .Path ("assets/about/jobs" )
109
108
jobs = []
110
109
for job_path in jobs_path .glob ("*.json" ):
111
- with open (job_path , mode = "r" , encoding = "utf-8" ) as jobfile :
110
+ with open (job_path , encoding = "utf-8" ) as jobfile :
112
111
job_obj = json .load (jobfile )
113
112
if job_obj ["endDate" ] is None :
114
113
job_obj ["endDate" ] = "current"
@@ -120,7 +119,7 @@ def about() -> str:
120
119
education_paths = pathlib .Path ("assets/about/education" )
121
120
educations = []
122
121
for education_path in education_paths .glob ("*.json" ):
123
- with open (education_path , mode = "r" , encoding = "utf-8" ) as edufile :
122
+ with open (education_path , encoding = "utf-8" ) as edufile :
124
123
edu_obj = json .load (edufile )
125
124
if edu_obj ["endYear" ] is None :
126
125
edu_obj ["endYear" ] = "current"
0 commit comments