Hi! I'd like to clear my variables after each "GET" for my web app.
My code declares two empty sets, builds those sets based on "POST" data from a form, and displays the web app with those variables if they exist. Like below!
entry = []
artist_info = []
@app.route("/", methods=["GET", "POST"])
def index():
if request.method == "GET":
return render_template("main_page.html", entry=entry, artist_info=artist_info)
entry.clear()
artist_info.clear()
# entry and artist_info are defined based on the "POST" data
Currently, the variables clear upon every "POST" request; I'd like them to clear after every "GET" request. I can't figure out how to do this as a successful GET seems to require a return
, preventing further code.
Any advice is appreciated, thanks so much!