Ejemplo n.º 1
0
def database():
    form = SearchForm()
    if form.validate_on_submit(
    ):  # if validates on sub then put it in lowercase and take the "@" sign if there is one
        form.username.data = form.username.data.lower()
        if form.username.data[0] == "@":
            form.username.data = form.username.data[1:]
        try:
            # if the user exists then report them
            scanning.get_twitter_info(form.username.data)
            return redirect(
                url_for("database_search", username=form.username.data,
                        page=1))
        except:
            flash(f"Sorry. That account does not exist", "danger")
    elif form.submit.data:
        flash(f"Sorry. That username is invalid.", "danger")
    page = request.args.get("page", 1, type=int)
    # fetch a paginated list of recent reports in order of date submitted desc
    reports = Report.query.order_by(
        Report.date_submitted.desc()).paginate(per_page=5)
    return render_template('database.html',
                           form=form,
                           reports=reports,
                           title="Database")
Ejemplo n.º 2
0
def index():
    form = SearchForm()
    if form.validate_on_submit():
        method = form.methods.data
        content = form.content.data
        if method == 1:
            return redirect(
                url_for('result.result_title', content=content, page=1))
        elif method == 2:
            return redirect(
                url_for('result.result_author', content=content, page=1))
        elif method == 3:
            return redirect(url_for('result.result_ISBN', content=content))
        else:
            return None
    return render_template('index.html', form=form)
Ejemplo n.º 3
0
def index():
    search = SearchForm()
    if search.validate_on_submit():
        sent = str(search.search.data)
        word_list = sent.split()
        results = []
        for x in word_list:
            places = retrievePlaces(x)
            if places is not None:
                for place in places:
                    results.append(place)
        return render_template('results.html',
                               results=results,
                               name=search.search.data)
    return render_template('index.html',
                           form=search,
                           current_user=current_user)
Ejemplo n.º 4
0
def main():
    form = SearchForm()
    if form.validate_on_submit():
        return render_template('index.html', page_title="Good", form=form)
    return render_template('index.html', page_title="Форму обошли", form=form)