Skip to content

Commit

Permalink
add error check for making first account
Browse files Browse the repository at this point in the history
if len(acc) is 0 in db
  • Loading branch information
jsmsj committed May 9, 2023
1 parent ef99334 commit 2ad58ff
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,23 @@ def x():
db = json.load(f)

if len(db['accounts']) == 0:
email = ff.Email()
res:Any = email.CreateAccount()
db['accounts'].append({'client':res.client,'sessionID':res.sessionID,'last_timestamp':0})
with open('db.json','w') as f:
f.write(json.dumps(db,indent=4))
try:
email = ff.Email()
res:Any = email.CreateAccount()
db['accounts'].append({'client':res.client,'sessionID':res.sessionID,'last_timestamp':0})
with open('db.json','w') as f:
f.write(json.dumps(db,indent=4))

redirect('/gpt4')
def x():
yield 'Successfully created account!\nRefresh to see it in accounts section'

return app.response_class(x(),mimetype='text/event-stream')
except Exception as e:
print(e)
def x():
yield 'Unable to create account, retrying might help'

return app.response_class(x(),mimetype='text/event-stream')

if make_new:
try:
Expand Down

0 comments on commit 2ad58ff

Please sign in to comment.