Question: I’m trying to use Flask in my pre-existing Replit file (as per a friend’s recommendation) in hopes of building a database that pulls up an animal that the user enters and I don’t think I did it properly. I’m not sure what happened, but after I copied and pasted my code and sorted the HTML, CSS, and JavaScript files into ‘static’ and ‘templates’, I keep getting a ‘Replit not Found error’, even when I move the index.html file out of the folder. Any help please?
Repl link: [REDACTED]
Here’s the python code just in case too, as everything was working fine before.
from flask import Flask, render_template, request
app = Flask(__name__)
# Dummy data for demonstration
aquatic_animals = [
{'ScientificClass': 'Scyphozoa', 'Phylum': 'Cnidaria'},
{'ScientificClass': 'Anthozoa', 'Phylum': 'Cnidaria'},
{'ScientificClass': 'Mammalia', 'Phylum': 'Chordata'},
{'ScientificClass': 'Actinopterygii', 'Phylum': 'Chordata'}
]
@app.route('/')
def index():
return render_template('index.html')
@app.route('/check_animal', methods=['POST'])
def check_animal():
# Retrieve user input
animal = request.form['animal']
# Check if the input matches any aquatic animal
for a_animal in aquatic_animals:
if animal.lower() == a_animal['ScientificClass'].lower() or animal.lower() == a_animal['Phylum'].lower():
return f"Yes, {animal} is an aquatic animal."
return f"No, {animal} is not found in our database of aquatic animals."
if __name__ == '__main__':
app.run(debug=True)