Rajkhanke007's picture
Create app.py
9a3cd95 verified
from flask import Flask, render_template, request
app = Flask(__name__)
# List of bird options
birds = [
"Amur_Falcon", "Bar-headed_Goose", "Blue-tailed_Bee-eater", "Cattle_Egret",
"Common_Crane", "Crab-Plover", "European_Bee-eater", "Gray_Nightjar",
"Greater_Whitethroat", "Indian_Blue_Robin", "Isabelline_and_Brown_Shrike",
"Northern_Wheatear", "Pallas_Fish-Eagle", "Red-headed_Bunting",
"Short-eared_Owl", "Whimbrel", "Wilson_Storm-Petrel", "Arctic_Warbler",
"Black_Baza", "Blyth_Reed_Warbler", "Chestnut-headed_Bee-eater",
"Common_Cuckoo", "Demoiselle_Crane", "European_Roller", "Gray-headed_Lapwing",
"Green_and_Greenish_Warbler", "Indian_Golden_Oriole", "Isabelline_Wheatear",
"Oriental_Pratincole", "Pied_Cuckoo", "Rosy_Starling", "Spot-winged_Starling",
"White-eyed_Buzzard", "Yellow-browed_Warbler", "Ashy_Drongo", "Black_Redstart",
"Brown-breasted_Flycatcher", "Chestnut-winged_Cuckoo", "Common_Greenshank",
"Desert_and_Pied_Wheatear", "Forest_Wagtail", "Great_Cormorant",
"Gull-billed_Tern", "Indian_Paradise-Flycatcher", "Kashmir_Flycatcher",
"Oriental_Turtle-Dove", "Red-breasted_and_Taiga_Flycatcher",
"Rufous-tailed_Scrub-Robin", "Spotted_Flycatcher", "White-throated_Needletail",
"Yellow-eyed_Pigeon", "Asian_Brown_Flycatcher", "Blue_Rock-Thrush",
"Brown-headed_Gull", "Collared_and_Oriental_Pratincole", "Common_Rosefinch",
"Eurasian_Wryneck", "Garganey", "Great_White_and_Dalmatian_Pelican",
"Hypocolius", "Indian_Pitta", "Little_Tern", "Pacific_Golden-Plover",
"Red-flanked_Bluetail", "Sanderling", "Tytler_Leaf_Warbler", "Willow_Warbler"
]
@app.route("/", methods=["GET", "POST"])
def index():
selected_bird = None
gif_url = None
if request.method == "POST":
selected_bird = request.form.get("bird")
if selected_bird:
gif_url = f"https://birdcount.in/wp-content/uploads/migration_maps/{selected_bird}.gif"
return render_template("index.html", birds=birds, selected_bird=selected_bird, gif_url=gif_url)
if __name__ == "__main__":
# Change to host="0.0.0.0" and port=7860 for deployment
app.run(host="0.0.0.0", port=7860)