1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 08:38:59 +00:00

handle connection errors on bot creation page

This commit is contained in:
Lynne Megido 2019-09-11 18:33:02 +10:00
parent f982e54a2d
commit 63722bb7a2

View file

@ -375,7 +375,13 @@ def bot_create():
session['instance'] = re.match(r"^(?:https?:\/\/)?(.*)", request.form['instance']).group(1) session['instance'] = re.match(r"^(?:https?:\/\/)?(.*)", request.form['instance']).group(1)
# check for mastodon/pleroma # check for mastodon/pleroma
try:
r = requests.get("https://{}/api/v1/instance".format(session['instance']), timeout=10) r = requests.get("https://{}/api/v1/instance".format(session['instance']), timeout=10)
except requests.ConnectionError:
session['error'] = "Couldn't connect to https://{}.".format(session['instance'])
except:
session['error'] = "An unknown error occurred while trying to load https://{}".format(session['instance'])
if r.status_code == 200: if r.status_code == 200:
j = r.json() j = r.json()
if "Pleroma" in j['version']: if "Pleroma" in j['version']: