Exemplo n.º 1
0
def add_deck():
    url = request.form['url']
    error = None
    if 'tappedout' in url:
        import decksite.scrapers.tappedout
        try:
            deck_id = decksite.scrapers.tappedout.scrape_url(url).id
        except (InvalidDataException, RequestException) as e:
            error = e.args[0]
    else:
        error = 'Deck host is not supported.'
    if error is not None:
        view = AddForm()
        view.error = error
        return view.page(), 409
    return redirect(url_for('deck', deck_id=deck_id))
Exemplo n.º 2
0
def add_deck() -> Union[wrappers.Response, Tuple[str, int]]:
    url = request.form['url']
    error = None
    if 'tappedout' in url:
        import decksite.scrapers.tappedout
        try:
            deck_id = decksite.scrapers.tappedout.scrape_url(url).id
        except (InvalidDataException, RequestException) as e:
            error = e.args[0]
    elif 'mtggoldfish' in url:
        import decksite.scrapers.mtggoldfish
        try:
            d = decksite.scrapers.mtggoldfish.scrape_one(url)
            deck_id = d.id
        except InvalidDataException as e:
            error = e.args[0]
    else:
        error = 'Deck host is not supported.'
    if error is not None:
        view = AddForm()
        view.error = error
        return view.page(), 409
    return redirect(url_for('deck', deck_id=deck_id))
Exemplo n.º 3
0
def add_form() -> str:
    view = AddForm()
    return view.page()