I want to return the URL for an image as JSON with jsonify. Everything is ok, but when I access the URL, error 404.
This is my code:
from flask import Flask, jsonify
import json
app = Flask(__name__)
with open("config.json") as f:
data = json.load(f)
cache_images = [img for img in os.listdir(data['altImg'])]
@app.route("/random.json")
def randomJSON():
return jsonify({ "link": data['domain'] + data['altImg'] + "/" + random.choice(cache_images)})
if __name__ == '__main__':
app.run(debug=True)
The output is: localhost:5000/images/amidamaru.jpg, which is correct but I can't find out why it gives me error 404.