Skip to content

Commit

Permalink
fixed connection handling
Browse files Browse the repository at this point in the history
  • Loading branch information
luona-dev committed Dec 4, 2023
1 parent 4c09088 commit 089c78c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion assets/guides/formbricks-in-gpts/formbricks_to_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def get_surveys(host: str, api_key: str) -> None:
Get all surveys from the Formbricks API and save them to surveys.json
"""
surveys = []
conn = None
try:
conn = http.client.HTTPSConnection(host, timeout=10)
headers = {
Expand All @@ -21,7 +22,8 @@ def get_surveys(host: str, api_key: str) -> None:
print("Omit the protocol (https://) and the trailing slash (/)")
exit(1)
finally:
conn.close()
if conn:
conn.close()
json.dump(data, open("surveys.json", "w"), indent=4)


Expand Down

0 comments on commit 089c78c

Please sign in to comment.