示例#1
0
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 !!'
示例#2
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))
    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("/")
示例#4
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)
示例#5
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)
示例#6
0
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')
示例#7
0
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')
示例#8
0
def index():
    return redirect("/static/examples.html")
示例#9
0
def scrape_mars_data():
    scrape_results = scrape_mars.scrape()
    mars_data.replace_one({}, scrape_results, upsert=True)
    return redirect('http://localhost:5000/', code=302)
示例#10
0
文件: app.py 项目: TomMcB/submissions
def home():
    if "logged_in" in session and session["logged_in"]:
        return render_template("home.html")
    else:
        return redirect(url_for("login"))
示例#11
0
def login():
    if request.method == "POST":
        user = request.form["nm"]
        return redirect(url_for("user", usr=user))
    else:
        return render_template("login.html")
示例#12
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")
示例#13
0
def delete_store(store_id):
    Store.get_by_id(store_id).remove_from_mongo()
    return redirect(url_for('.index'))