Ejemplo n.º 1
0
def search(search):
    if request.method == 'POST':
        searchTerm = request.form['search_term'].replace(' ', '-')
        return redirect(url_for('search', search=searchTerm))

    return render_template("result.html",
                           title_list=scrape(search),
                           pageTitle="%s News Results" % (search))
Ejemplo n.º 2
0
def login():
    if request.method == "GET":
        if "logged_in" in session and session["logged_in"]:
            return render_template(url_for("home"))
        else:
            return render_template("login.html")
    else:
        return "not get"
Ejemplo n.º 3
0
def add_results():
    form = StudentForm()
    if form.validate_on_submit():
        student = Student(
            name=form.name.data,
            physics=form.physics.data,
            maths=form.maths.data,
            chemistry=form.chemistry.data,
        )
        db.session.add(student)
        db.session.commit()
        return redirect(url_for('add_results'))
    else:
        return render_template('home.html', form=form)
Ejemplo n.º 4
0
def edit_store(store_id):
    store = Store.get_by_id(store_id)

    if request.method == 'POST':
        name = request.form['name']
        url_prefix = request.form['url_prefix']
        tag_name = request.form['tag_name']
        query = json.loads(request.form['query'])

        store.name = name
        store.url_prefix = url_prefix
        store.tag_name = tag_name
        store.query = query

        store.save_to_mongo()

        return redirect(url_for('.index'))
    
    return render_template('stores/edit_store.html', store=store)
Ejemplo n.º 5
0
def home():
    if "logged_in" in session and session["logged_in"]:
        return render_template("home.html")
    else:
        return redirect(url_for("login"))
Ejemplo n.º 6
0
def login():
    if request.method == "POST":
        user = request.form["nm"]
        return redirect(url_for("user", usr=user))
    else:
        return render_template("login.html")
Ejemplo n.º 7
0
def index():
    if request.method == 'POST':
        searchTerm = request.form['search_term'].replace(' ', '-')
        return redirect(url_for('search', search=searchTerm))

    return render_template("index.html", pageTitle="Google News Webscraper")
Ejemplo n.º 8
0
def delete_store(store_id):
    Store.get_by_id(store_id).remove_from_mongo()
    return redirect(url_for('.index'))