Commit 14ca843c5bb32b7a0e789237c7f42f50dbc8dd6f

  • avatar
  • arvind
  • Tue Aug 26 13:02:45 IST 2014
Adding API for getting media type of a resource at an URL.
  
220220 style.set("type", "text/css")
221221
222222
223@app.route('/getMediaType')
224def getMediaType():
225 request = requests.get(flask.request.args['where'])
226 content = request.text
227 if imghdr.what('ignore', content) is None:
228 return flask.jsonify({'type': 'html'})
229 else:
230 return flask.jsonify({'type': 'image'})
231
223232# if the app is run directly from command-line
224233# assume its being run locally in a dev environment
225234if __name__ == '__main__':