I have a decently intermediate understanding of APIs, and am not trying to host information I've got from APIs onto the web.
This incredibly simple code:
from flask import Flask, request, render_template import requests app = Flask(__name__) @app.route('/temperature', methods=['POST']) def temperature(): zipcode = request.form['zip'] r = requests.get('http://api.openweathermap.org/data/2.5/weather?zip=' +zipcode+',us&appid=9b56b06ab4c7f06821ccf55e3e10fce5') json_obj = r.text return json_obj @app.route('/') def index(): return 'hi' if __name__ == '__main__': app.run(debug=True) Is not giving me anything (except the 405 error).
Can someone please explain why my POST method is not working?
GET. You need to write test code to usePOST. For examplerequests.post('http://127.0.0.1:5000/temperature', {'zip': '12345'})/temperaturepage.