Simplifying routing a bit helps me to check which endpoint the user is visiting. Also will make it a lot easier down the road to rewrite, whenever I get around to renaming "autocomplete" to a more appropriate name (like "suggestion" or something).
23 lines
477 B
Python
23 lines
477 B
Python
from enum import Enum
|
|
|
|
|
|
class Endpoint(Enum):
|
|
autocomplete = 'autocomplete'
|
|
home = 'home'
|
|
healthz = 'healthz'
|
|
session = 'session'
|
|
config = 'config'
|
|
opensearch = 'opensearch.xml'
|
|
search = 'search'
|
|
search_html = 'search.html'
|
|
url = 'url'
|
|
imgres = 'imgres'
|
|
element = 'element'
|
|
window = 'window'
|
|
|
|
def __repr__(self):
|
|
return self.value
|
|
|
|
def in_path(self, path: str) -> bool:
|
|
return path.startswith(self.value)
|