def user_decks(user_id): user = current_user form = URLForm() url = '' if form.validate_on_submit(): url = form.url.data ad = ArticleDeck.query.filter_by(url=url) if any(a for a in ad): deck = ad[0] ud = UserDeck.query.filter_by(user=user, deck=deck) if not any(d for d in ud): ud = UserDeck(user=user) ud.populate(ad[0]) else: scraper = get_scraper(url) dm = DeckMaker(scraper.process_page()) deck = dm.create_article(title=scraper.title, url=scraper.url) ud = UserDeck(user=user) ud.populate(deck) decks = user.get_decks() return render_template('user_decks.html', title='My decks', url=url, form=form, user=user, user_decks=decks)
def index(): form = URLForm() if form.validate_on_submit(): url = form.url.data session['url'] = url return redirect(url_for('processing')) return render_template('url.html', title='Sign In', form=form)
def index(): form = URLForm() if form.validate_on_submit(): if not validators.url(form.url.data): return jsonify(success=False) alias = URLMap.insert(form.url.data) return jsonify(success=True, alias=alias) return render_template('index.html', form=form)
def index(): form = URLForm() form.name.choices = [(a.id, a.name) for a in Product.query.order_by('name')] if form.validate_on_submit(): return render_template('/product page/<name>', form=form) return render_template('index.html', form=form, product=Product)
def thumbnail(): """Fetch the thumbnail for an URL.""" form = URLForm() thumbnail_url = None if form.validate_on_submit(): # thumbnail_url = fetch_thumbnail(form.url.data) pass return render_template('tests/fetch_thumbnail.html', form = form, thumbnail_url = thumbnail_url)
def read(): """Fetch the readable content from an URL.""" form = URLForm() readable = None if form.validate_on_submit(): html = fetch_html(form.url.data) readable = get_readable(html, form.url.data) return render_template('tests/fetch_article.html', form = form, html_readable = readable)
def url(): form = URLForm() if form.validate_on_submit(): result = perform_url_request(form.url.data, form.task.data) return render_template('result.html', title='Results', res=result, task=form.task.data.lower()) return render_template('url.html', title='URL', form=form)
def new_task(): # TODO: validate URL form_for_url = URLForm() if form_for_url.validate_on_submit(): task_id = uuid.uuid4().hex db.session.add(Task(id=task_id, url=form_for_url.URL.data, status='added')) db.session.commit() send_task(task_id) flash('Your URL: {0} parsing with task №{1}'.format(form_for_url.URL.data, task_id)) return task_id return redirect(url_for('index'))
def index(): form = URLForm() if form.validate_on_submit(): flash('Playlist requested for URL {}'.format(form.url.data)) session['reddit_url'] = form.url.data sp_oauth = spotipy.oauth2.SpotifyOAuth(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, scope=SCOPE) auth_url = sp_oauth.get_authorize_url() print(auth_url) return redirect(auth_url) if 'result' in session: return render_template('base.html', form=form, result=session.pop('result', None), now=datetime.utcnow()) else: return render_template('base.html', form=form, now=datetime.utcnow())
def url(): form = URLForm() if form.validate_on_submit(): return redirect(url_for('processing', input_url=form.input_url.data)) return render_template('URL.html', title='Spotify 2019', form=form)