Plotting Maps offline, bypass the CDN

Hi All,

I’m running Plotly exclusively out of a Jupyter Lab environment that is air-gapped from the internet.
My main use case is to produce charts that I export as SVG to be later added in static presentations.

Everything was fine until I tried doing maps.

I have this simple code to display in blue some European countries:

import plotly.express as px
import pandas as pd
import plotly.graph_objects as go

# Create a GeoDataFrame or DataFrame with European countries and their color
data = {
    "Country": ["France", "Germany", "Italy", "Spain", "United Kingdom", "Greece", "Portugal"],
    "Color": ["blue"] * 7
}
df = pd.DataFrame(data)

# Create a choropleth map using Plotly Express
fig = px.choropleth(
    df,
    locations="Country",
    color="Color",
    locationmode="country names",
    title="European Countries with Outlines",
    projection="natural earth",
)

# Customize the map layout
fig.update_geos(
    showcoastlines=True,
    coastlinecolor="black",  # Color of country outlines
)
fig.show()

Which gives me a blank space in my notebook with an error message at the bottom:
Javascript Error: unexpected error while fetching topojson file at https://cdn.plot.ly/world_110m.json

I have tried this solution : Offline Scattergeo plots not working - #3 by carlmarl

That consist of running a Flask app that acts as a simple webserver and deliver the required .json through a local URL.

But, when I run the code above with a config tweak :

# ... rest of the code...
# Show the map
fig.show(config={'topojsonURL':'http://127.0.0.1:5000/plotlygeojsonfile/plotly/topojson/'})

I get the same blank map with a new error message: Javascript Error: unexpected error while fetching topojson file at http://127.0.0.1:5000/plotlygeojsonfile/plotly/topojson/world_110m.json

Which is interresting because it seems the new URL is accepted. But I see nothing in the logs of my Flask app. The URL was never reached.

Not, I’ve tested the server with a simple script:

import requests

file_url = "http://127.0.0.1:5000/plotlygeojsonfile/plotly/topojson/world_110m.json"  # Replace with the correct URL

response = requests.head(file_url)

if response.status_code == 200:
    print("File is available.")
else:
    print("File is not available.")

And it returns “File is available” and the app logs shows it has been reached.

I’ve been searching for a solution for a couple of days but nothing. There seem to be things possible with Dash but I don’t know Dash at all. Like in this topic Loading geo assets offline [Solved] - #3 by zoohair