-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
32 lines (23 loc) · 651 Bytes
/
Copy pathapi.py
File metadata and controls
32 lines (23 loc) · 651 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import flask
from flask import request, jsonify
from flask import json
from pathlib import Path
import weather as w
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
return "<h1> Test </h1><p> api endpoint for test /check </p>"
@app.route('/check', methods=['GET'])
def check():
if 'city' in request.args:
city = request.args.get('city')
print(city)
result = w.main(city)
return result
else:
return { "error": "True" }
@app.errorhandler(404)
def page_not_found(e):
return "<h1>404</h1><p>The page could not be found.</p>", 404
app.run()