I have a GET and PUT request built below:
from flask import Flask from flask_restful import Api, Resource, reqparse app = Flask(__name__) api = Api(app) userStorage =[ { "id": "1234", "currentBot": "BestBot" } ] class User(Resource): def get(self, id): for user in userStorage: if(id == user["id"]): return user, 200 return "User not found", 404 def put(self, id): parser = reqparse.RequestParser() parser.add_argument("currentBot") args = parser.parse_args() for user in userStorage: if(id == user["id"]): user["currentBot"] = args["currentBot"] return user, 200 user = { "id": id, "currentBot": args["currentBot"] } userStorage.append(user) return user, 201 def delete(self, id): global userStorage userStorage = [user for user in userStorage if user["id"] != id] return "{} is deleted.".format(id), 200 api.add_resource(User, "/user/<string:id>") app.run(debug = True, port = 4000) Postman can properly get a response 200 when I do a simple get request but when I try to do a request through my own program it returns a 404
import requests payload2Storage = { "currentBot": "BestBot" } headers = {"Content-Type": "application/json"} params = { "id": "1234" } #response = requests.request("PUT", "http://127.0.0.1:4000/user/", data=payload2Storage, params=params, headers=headers) response2 = requests.request("GET", "http://127.0.0.1:4000/user/", params=params, headers=headers) Is there something wrong with my request to get the info from userStorage?