def structure_in_data(data: Dict): temp = Users() for item in data: user = temp.add_user(item["name"]) if len(item["owes"]) > 0: user.owes = item["owes"] if len(item["owed_by"]) > 0: user.owed_by = item["owed_by"] user.adjust_balance() return temp
def second_page(): if request.method == 'POST': fname = request.form['fname'] lname = request.form['lname'] username = request.form['username'] password = request.form['password'] Users.sign(fname, lname, username, password) return render_template("login.html") else: return render_template("login.html")
def home_page(): user_name = request.form['user_name'] password = request.form['password'] if Users.login(user_name, password): user = user_name else: user = None return render_template("home.html")
def init(): temp = Users() temp.add_user("Adam") temp.add_user("Bob") temp.add_user("Carl") temp.add_iou("Adam", "Bob", 4) temp.add_iou("Carl", "Bob", 4) temp.add_iou("Adam", "Bob", 4) temp.add_iou("Bob", "Carl", 3.4) temp.add_iou("Bob", "Adam", 3) return write_data_out(temp, URL)
def init(): user_list = Users() user_list.add_user("Adam") user_list.add_user("Bob") user_list.add_user("Carl") user_list.add_iou("Adam", "Bob", 5), user_list.add_iou("Bob", "Adam", 5), user_list.add_iou("Bob", "Adam", 5) return user_list
def test_gib_list_noname(): temp = Users() with pytest.raises(Exception): temp.gib_list("Adam")
def test_gib_list_fail(): temp = Users() with pytest.raises(Exception): temp.gib_list()
from flask import Flask, render_template, request from src.json_formatter import format_json from src.asn1_codec import Asn1Codec from src.users import Users from src.file_selector import FileSelector import json import os app = Flask(__name__) users = Users(os.path.join(os.getcwd(), "users")) def get_user(ip_addr): user = users.get_user_by_ip(request.remote_addr) return users.add_user(request.remote_addr) if user is None else user def get_asn1codec(user): if user.asn1codec is None: user.create_asn1codec_data_dir() user.asn1codec = Asn1Codec(user.asn1codec_files['py_file']) return user.asn1codec def get_file_selector(user): if user.file_selector is None: user.file_selector = FileSelector() return user.file_selector @app.route('/')