-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Police-Data-Accessibility-Project/mc_issu…
…e_285_refactor_search_tokens Mc issue 285 refactor search tokens
- Loading branch information
Showing
13 changed files
with
310 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import datetime | ||
import uuid | ||
|
||
|
||
def insert_access_token(cursor): | ||
token = uuid.uuid4().hex | ||
expiration = datetime.datetime.now() + datetime.timedelta(minutes=5) | ||
cursor.execute( | ||
f"insert into access_tokens (token, expiration_date) values (%s, %s)", | ||
(token, expiration), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import datetime | ||
import uuid | ||
|
||
|
||
def insert_new_access_token(cursor): | ||
token = uuid.uuid4().hex | ||
expiration = datetime.datetime.now() + datetime.timedelta(minutes=5) | ||
cursor.execute( | ||
f"insert into access_tokens (token, expiration_date) values (%s, %s)", | ||
(token, expiration), | ||
) | ||
return token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import json | ||
import os | ||
|
||
import requests | ||
|
||
|
||
def post_to_webhook(data: str): | ||
webhook_url = os.getenv("WEBHOOK_URL") | ||
|
||
requests.post( | ||
webhook_url, | ||
data=data, | ||
headers={"Content-Type": "application/json"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.