def lookup_oembed(): from flask import current_app content_url = request.form.get('content_url') (discovered_format, oembed_url) = discovery.get_oembed_url( content_url, max_width=300, max_height=300) current_app.logger.debug(oembed_url) response = requests.get(oembed_url) oembed_fields = json.loads(response.text) return jsonify(oembed_fields)
def create(): json_data = request.get_json(force=True) try: (discovered_format, oembed_url) = get_oembed_url(json_data['scrap'], max_width=300, max_height=300) except PyEmbedDiscoveryError: return error("Invalid oEmbed resource URL", 400) except KeyError: return error("POST to /api/scraps takes one parameter, scrap", 400) response = requests.get(oembed_url) oembed_fields = json.loads(response.text) s = Scrapbook(json_data['scrap'], **oembed_fields) db_session.add(s) db_session.commit() return jsonify({"scrap": url_for('get', **{'scrap_id': s.id})}), 201