KavinduHansaka's picture
Update app.py
a8fdef3 verified
raw
history blame
508 Bytes
from flask import Flask, request, jsonify
import requests
app = Flask(__name__)
API_KEY = "6d0b5a223205f8e88b2b9d45a0ad532a"
@app.route("/get_weather", methods=["GET"])
@app.route("/")
def index():
return "✅ Weather API is running!"
def get_weather():
city = request.args.get("city")
res = requests.get(f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}&units=metric")
return jsonify(res.json())
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7860)