Added connection check to projects blueprint

This commit is contained in:
2026-06-10 07:52:04 +01:00
parent 322c09f10a
commit 82347e4b78

View File

@ -31,12 +31,15 @@ class Blueprint(flask.Blueprint):
self._apiKey = os.getenv('GITEA_TOKEN') self._apiKey = os.getenv('GITEA_TOKEN')
self.giteaUID = None self.giteaUID = None
r = requests.get(self.constructURL('/api/v1/user'), timeout=5) try:
r = requests.get(self.constructURL('/api/v1/user'), timeout=5)
if r.ok: if r.ok:
self.giteaUID = r.json().get('id') self.giteaUID = r.json().get('id')
else: else:
log.error('Cannot get Gitea user ID. This blueprint will not work.') log.error('Cannot get Gitea user ID. This blueprint will not work.')
except requests.exceptions.ConnectionError:
log.error('Failed to connect to Gitea server. This blueprint will not work.')
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)