Spaces:
Runtime error
Runtime error
Link Chemiscope load param to dataset json
Browse files318 unmodified lines319320321322323324325326327328329330331332333334318 unmodified linesviewer_path = dataset_file.parent / viewer_nameviewer_path.write_text(combined, encoding="utf-8")view_rel_path = viewer_path.as_posix()return ("<div style='width:100%;'>""<iframe ""title='Chemiscope explorer' ""style='width:100%;height:620px;border:none;border-radius:8px;' "f"src='https://chemiscope.org/?load={urllib.parse.quote(view_rel_path)}'></iframe>""<p style='font-size:0.9em;margin-top:0.5rem;'>""Open in a new tab if the viewer looks blank: "f"<a href='https://chemiscope.org/?load={urllib.parse.quote(view_rel_path)}' target='_blank' rel='noopener'>Chemiscope standalone</a>""</p>""</div>")318 unmodified lines319320321322323324325326327328329330331332333334335336337338339340341342343344318 unmodified linesviewer_path = dataset_file.parent / viewer_nameviewer_path.write_text(combined, encoding="utf-8")space_origin = _infer_space_origin()if space_origin:dataset_url = f"{space_origin}/file={dataset_file.as_posix()}"load_param = urllib.parse.quote(dataset_url, safe=":/?=&%")iframe_src = f"https://chemiscope.org/?load={load_param}"link = iframe_srcelse:encoded = base64.b64encode(combined.encode("utf-8")).decode("ascii")iframe_src = f"data:text/html;base64,{encoded}"link = iframe_srcreturn ("<div style='width:100%;'>""<iframe ""title='Chemiscope explorer' ""style='width:100%;height:620px;border:none;border-radius:8px;' "f"src='{iframe_src}'></iframe>""<p style='font-size:0.9em;margin-top:0.5rem;'>""Open in a new tab if the viewer looks blank: "f"<a href='{link}' target='_blank' rel='noopener'>Chemiscope standalone</a>""</p>""</div>")
app.py+13-3