def submit_form(): if request.method == 'POST': data = request.form.to_dict() #print(data) write_to_csv(data) return redirect('/database.html') else: return 'something went wrong !!'
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))
def scrape(): #Run the scraped functions mars_info = mongo.db.mars_info mars_data = scrape_mars.scrape_mars_news() mars_data = scrape_mars.scrape_mars_image() mars_data = scrape_mars.scrape_mars_facts() mars_data = scrape_mars.scrape_mars_weather() mars_data = scrape_mars.scrape_mars_hemisspheres() mars_info.update({}, mars_data, upsert=True) return redirect("/")
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)
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)
def handleNewForm(): print("This should print") name = request.form['name'] goal1 = request.form['goal1'] goal2 = request.form['goal2'] goal3 = request.form['goal3'] url = request.form['url'] description = request.form['projectDescription'] mycursor = mydb.cursor() # use mysql.connector and the variables and above to update the new information from the webpage into the database # sql = "UPDATE INTO projects(repoName, url, goal1, goal2, goal3) VALUES (%s, %s, %s, %s, %s)" # val = (name, goal1, goal2, goal3, url) # mycursor.execute(sql, val) mydb.commit() print("The name is " +name) return redirect('/newForm.html')
def handleNewForm(): print("This should print") name = request.form['name'] goal1 = request.form['goal1'] goal2 = request.form['goal2'] goal3 = request.form['goal3'] url = request.form['url'] description = request.form['projectDescription'] mycursor = mydb.cursor() sql = "INSERT INTO repo_info(repoName, url, goal1, goal2, goal3) VALUES (%s, %s, %s, %s, %s)" val = (name, goal1, goal2, goal3, url) mycursor.execute(sql, val) mydb.commit() print("The name is " + name) return redirect('/NewForm.vue')
def index(): return redirect("/static/examples.html")
def scrape_mars_data(): scrape_results = scrape_mars.scrape() mars_data.replace_one({}, scrape_results, upsert=True) return redirect('http://localhost:5000/', code=302)
def home(): if "logged_in" in session and session["logged_in"]: return render_template("home.html") else: return redirect(url_for("login"))
def login(): if request.method == "POST": user = request.form["nm"] return redirect(url_for("user", usr=user)) else: return render_template("login.html")
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")
def delete_store(store_id): Store.get_by_id(store_id).remove_from_mongo() return redirect(url_for('.index'))