def send_marker(filename): if not os.path.exists('markers'): os.makedirs('markers') requested_filename = 'markers/{}'.format(filename) if os.path.isfile(requested_filename): return send_file(requested_filename, mimetype='image/png') else: result = re_pattern_marker.match(filename) if result is not None: cn = result.group(1) style = result.group(3) marker_filename = create_marker(cn, style) return send_file(marker_filename, mimetype='image/png') else: return("File {} neither found nor created".format(filename))
def test_markers(self): self.assertEqual(create_marker('MY', 'g'), 'markers/MY_g.png')