Forums

Simple Flask App Not Returning Index.html

I'm attempting to run 2 types of commands in my Flask App and function named extract_subpath works fine but my index function does not and vice versa.

does anyone have any solutions? i'm a beginner in flask as well.


from flask import Flask, render_template, request, flash, redirect

app = Flask(__name__)

@app.route('/')
def index(): return render_template("index.html")

@app.route('/<path:subpath>')
def extract_subpath(subpath):
    # print({subpath})
    # return f"The subpath is: {subpath}"
    redirect_url = "sms:123456789?&body=" + subpath
    return redirect(redirect_url, code=302)

[edit by admin: formatting]

What happens when you access the root view of your site (the one with @app.route('/'))? I visited http://bennyjigs.pythonanywhere.com/ just now, and got an internal server error message; that would point to a bug in your code, and you can debug that by looking at the website's error log -- there's a link to it on the "Web" page inside PythonAnywhere, and the most recent error message will be at the bottom of the file.