I’m writing APIs for a mobile app and now we need a “check for new version” api, which would look like this:
{
version: 1.3,
url: "http://abc.com/v1.3.apk",
change_log: "Fix few bugs"
}
Now I’d like to know what’s the best practice when writing such an api, is it all right to hard code those infos in the server side code(flask, in my case):
@app.route("/update")
@jsonify
def checkForUpdate():
return {
version: 1.3,
url: "http://abc.com/v1.3.apk",
change_log: "Fix few bugs"
}
or is there better idea?
Hardcoding version information is probably a last-resort kind of solution. I would have a static file with the JSON content generated at deploy time. Then you could serve it statically (configuring the correct MIME type directly at the web server) or by reading it from your web application.