Created
July 8, 2025 16:12
-
-
Save danielaRiesgo/ff0eff9ffe62e2ba39159a5b23becc0c to your computer and use it in GitHub Desktop.
Scripts to read and compare endpoints across versions of the app
This file contains hidden or 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
BEFORE_FILE = 'endpoints_before.txt' | |
AFTER_FILE = 'endpoints_after.txt' | |
# Copied: termcolor library | |
COLORS: dict[str, int] = { | |
"black": 30, | |
"red": 31, | |
"green": 32, | |
"yellow": 33, | |
"blue": 34, | |
"magenta": 35, | |
"cyan": 36, | |
"light_grey": 37, | |
"dark_grey": 90, | |
"light_red": 91, | |
"light_green": 92, | |
"light_yellow": 93, | |
"light_blue": 94, | |
"light_magenta": 95, | |
"light_cyan": 96, | |
"white": 97, | |
} | |
def colored(text, color): | |
fmt_str = "\033[%dm%s\033[0m" | |
return fmt_str % (COLORS[color], text) | |
def get_differences(before_path: str, after_path: str) -> tuple[list[str], list[str]]: | |
"""Returns (removed, added).""" | |
with open(before_path) as before_file, open(after_path) as after_file: | |
before = before_file.readlines() | |
before = [line.strip() for line in before] | |
after = after_file.readlines() | |
after = [line.strip() for line in after] | |
added = [] | |
removed = [] | |
for endpoint in before: | |
if endpoint not in after: | |
removed.append(endpoint) | |
for endpoint in after: | |
if endpoint not in before: | |
added.append(endpoint) | |
return (removed, added) | |
def main(): | |
removed, added = get_differences(BEFORE_FILE, AFTER_FILE) | |
print(colored("REMOVED:", "red")) | |
for endpoint in removed: | |
print(colored("\t" + endpoint, "red")) | |
print(colored("ADDED:", "green")) | |
for endpoint in added: | |
print(colored("\t" + endpoint, "green")) | |
main() |
This file contains hidden or 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
""" | |
Run with `pipenv run python get_endpoints.py > endpoints_after.txt` or `endpoints_before.txt`. | |
""" | |
from sleep_coach.flask.root import app | |
with app.test_request_context(): | |
for rule in app.url_map.iter_rules(): | |
print(rule.rule) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment