102
102
"clientId" : "meetup_bot" ,
103
103
}
104
104
105
+
105
106
@app .post ("/token" , response_model = Token )
106
107
async def login_for_oauth_token (response : Response , form_data : OAuth2PasswordRequestForm = oauth_form_dependency ):
107
108
"""Login for oauth access token"""
@@ -130,16 +131,19 @@ async def login_for_oauth_token(response: Response, form_data: OAuth2PasswordReq
130
131
131
132
return {"access_token" : oauth_token , "token_type" : "bearer" }
132
133
134
+
133
135
@app .get ("/healthz" , status_code = 200 )
134
136
def health_check ():
135
137
"""Smoke test to check if the app is running"""
136
138
return {"status" : "ok" }
137
139
140
+
138
141
@app .get ("/" , response_class = HTMLResponse )
139
142
def index (request : Request ):
140
143
with open (Path ("resources/templates/login.html" )) as f :
141
144
return HTMLResponse (content = f .read (), status_code = 200 )
142
145
146
+
143
147
@app .post ("/auth/login" )
144
148
def login (request : Request , username : str = Form (...), password : str = Form (...)):
145
149
"""Redirect to "/docs" from index page if user successfully logs in with HTML form"""
@@ -169,6 +173,7 @@ def login(request: Request, username: str = Form(...), password: str = Form(...)
169
173
detail = "Incorrect username or password"
170
174
)
171
175
176
+
172
177
@api_router .get ("/token" )
173
178
def generate_token (current_user : User = current_active_user_dependency ):
174
179
"""
@@ -195,6 +200,7 @@ def generate_token(current_user: User = current_active_user_dependency):
195
200
196
201
return access_token , refresh_token
197
202
203
+
198
204
@api_router .get ("/events" )
199
205
def get_events (auth : dict = ip_whitelist_auth_dependency ,
200
206
location : str = "Oklahoma City" ,
@@ -225,6 +231,7 @@ def get_events(auth: dict = ip_whitelist_auth_dependency,
225
231
226
232
return events
227
233
234
+
228
235
@api_router .get ("/check-schedule" )
229
236
def should_post_to_slack (auth : dict = ip_whitelist_auth_dependency , request : Request = None ):
230
237
"""
@@ -267,6 +274,7 @@ def should_post_to_slack(auth: dict = ip_whitelist_auth_dependency, request: Req
267
274
"should_post" : False ,
268
275
}
269
276
277
+
270
278
@api_router .post ("/slack" )
271
279
def post_slack (
272
280
auth : dict = ip_whitelist_auth_dependency ,
@@ -321,6 +329,7 @@ def post_slack(
321
329
except Exception as e :
322
330
return {"message" : f"Error posting to Slack: { str (e )} " , "status" : "error" }
323
331
332
+
324
333
@api_router .post ("/snooze" )
325
334
def snooze_slack_post (
326
335
duration : str ,
@@ -350,6 +359,7 @@ def snooze_slack_post(
350
359
except ValueError as e :
351
360
raise HTTPException (status_code = 400 , detail = str (e )) from e
352
361
362
+
353
363
@api_router .get ("/schedule" )
354
364
def get_current_schedule (auth : dict | User = ip_whitelist_auth_dependency ):
355
365
"""
@@ -375,6 +385,7 @@ def get_current_schedule(auth: dict | User = ip_whitelist_auth_dependency):
375
385
376
386
return {"schedules" : schedules }
377
387
388
+
378
389
# routes
379
390
app .include_router (api_router )
380
391
0 commit comments