def settings(): conf = data.get_conf() if 'user' not in conf: info = requests.post(sync.root + "/sign_up", { "name": platform.node() }).json() conf['user'] = info['user'] conf['secret'] = info['secret'] conf['friends'] = conf.get('friends', []) conf['dir'] = data.default_dir if not os.path.exists(conf['dir']): os.mkdir(conf['dir']) conf['email'] = "" data.save_conf(conf) if flask.request.method == 'GET': args = copy.copy(conf) args['msg'] = flask.request.args.get('msg', None) return templ8("ui.html", args) elif flask.request.method == 'POST': conf['dir'] = flask.request.form.get('dir') conf['email'] = flask.request.form.get('email') sync.postjson('/set_email', { "user": conf['user'], "secret": conf['secret'], "email": conf['email'] }) data.save_conf(conf) return flask.redirect('/ui?msg=Saved') return "Saved!"
def restore(user, secret): conf = data.get_conf() conf['user'] = user conf['secret'] = secret conf['friends'] = [] postjson('/restore', {"user": conf['user'], "secret": conf['secret']}) data.save_conf(conf) return flask.redirect('/ui?msg=Now%20pick%20a%20folder%20and%20wait%20for%20your%20files:')
def email_restore_key(): email = flask.request.form.get('email') if email: sync.postjson('/send_email', {"email": email}) return flask.redirect('/ui?msg=Okay,%20check%20your%20email.')