Spaces:
Sleeping
Sleeping
Create app.py
Browse files
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)
|