Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 19113

Keep getting 404 error when redirecting using Flask

$
0
0

I have been making a website. In the website the user enters some fields and starts the scraping process. When the process is finished I want the code to redirect user to the following route:

@app.route('/scraping-finished')def scraping_finished():    return render_template('scraping_finished.html')

The functions that should redirect the user is the following:

def run_scraper(city, subregion, apart_or_house, words_to_check):    # Ask the user for input    base_url = ""    while True:        if city != "":            break        else:            flash("City name cannot be empty. Please enter a valid city name.", "error")            return    while True:        if apart_or_house == "wohnung" or apart_or_house == 'haus':            break        elif apart_or_house == "":            flash("This field cannot be empty. Please enter what are you buying.", "error")        else:            flash("Please enter either 'wohnung' or 'haus'.", "error")            return    if subregion:        base_url = f"https://www.immobilienscout24.de/Suche/de/{city}/{city}/{subregion}/{apart_or_house}-kaufen"    else:        base_url = f"https://www.immobilienscout24.de/Suche/de/{city}/{city}/{apart_or_house}-kaufen"    # Run the scraper script with the provided inputs and base_url    subprocess.run(['python', 'scraper.py', city, subregion, apart_or_house, base_url, words_to_check])    return redirect(url_for('scraping_finished'))

But at when the scraping is over, and the program should redirect I get the following error on the browser:

enter image description here

Why is this happening? I have checked my spelling and everything is okey, and I have also restarted the server couple of times.


Viewing all articles
Browse latest Browse all 19113

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>