whoogle-search/app/models/endpoint.py
Ben Busby 74e9317053
Override __str__ for endpoint f-strings
By default, f-strings use __str__ not __repr__, unless supplied with a
"!r" at the end of the str. Rather than going through and making the
strings work for the overridden __repr__ for endpoints, it's easier just
to convert the method over to __str__.

Also cleaned up some broken routes and formatting.
2021-11-16 20:05:42 -07:00

24 lines
530 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 __str__(self):
return self.value
def in_path(self, path: str) -> bool:
return path.startswith(self.value) or \
path.startswith(f'/{self.value}')