How to load mesh to Cesium via Flask?

I want to view mesh data in Cesium serving file from my local disk, make my own ‘server’ but I don’t know how. Here is what I tried to do.

I have this catalog structure:

server.py
templates
  -index.html
static
  -b3dm files
  -tileset.json

This is server.py file:

from flask import Flask, render_template, current_app

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route("/tileset")
def tileset():
    return current_app.send_static_file('tileset.json')

if __name__ == '__main__':
    app.run(debug=True)

This is part from index.html:

<div id="cesiumContainer"></div>
<script type="module">
    Cesium.Ion.defaultAccessToken = 'token';
    
    const viewer = new Cesium.Viewer('cesiumContainer');
    
    viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(21.025, 52.270, 500)
    });
    
    var tileset = viewer.scene.primitives.add(
        new Cesium.Cesium3DTileset({
            url: "http://127.0.0.1:5000/tileset"
        })
    );
</script>

Under http://127.0.0.1:5000/tileset json file displays correctly in the browser but mesh data doesn’t load in cesium viewer under index at http://127.0.0.1:5000.
Maybe I’m missing the whole point of how server should work, please correcr me if I’m wrong.
Why Flask? Because I’m somehow familiar with Python and I don’nt have permissions to install other software on my work computer.

Hi,

The server will need to provide access to all the data in the tileset folder, not just tileset.json. tileset.json describes the structure of the files, but the other files in the folder actually contain the mesh data.

Thank you for your answer.
So how to serve .b3dm files with Flask? Is it possible this way?
Or maybe it’s better to use other software e.g. Apache Tomcat, Geoserver?
I know that I’m missing a lot in this topic. It was easy to copy html with predefined code to show OSM buildings in Cesium, but could you point me to some resources that will show me how to create my own server hosting .b3dm files from a local disk?

Any web server software that can serve out a static directory structure of files can host 3d tilesets. For a low volume or local development, the best answer is whatever you are most familiar with and is easy to set up.

Flask may have an option for how to host a whole directory. The best place to get that information would be in the Flask documentation or with their support.