KavinduHansaka commited on
Commit
221e2fc
·
verified ·
1 Parent(s): 02ef32a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ import requests
3
+
4
+ app = Flask(__name__)
5
+
6
+ API_KEY = "6d0b5a223205f8e88b2b9d45a0ad532a"
7
+
8
+ @app.route("/get_weather", methods=["GET"])
9
+ def get_weather():
10
+ city = request.args.get("city")
11
+ res = requests.get(f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}&units=metric")
12
+ return jsonify(res.json())
13
+
14
+ if __name__ == "__main__":
15
+ app.run(host="0.0.0.0", port=7860)