I have an html that needs multiple javascript files in order to work. They all need to be imported using javascript function importModules. This is a function in another javascript file that has routes to all the modules that are needed. The html file works fine if when I open it up in web browser. However when I tried to use Bottle, it doesn't upload those libraries. The root tree looks something like this:
\---javascript
| something1.js
| something2.js
\---_libraries
\---lib1
| one.js
| two.js
|
+---lib1.1
| three.js
| four.js
|
+---lib1.2
| +---lib1.2.1
| | five.js
| | six.js
| | seven.js
| |
| +---lib1.2.2
| | eight.js
| |
| +---lib1.2.3
| | nine.js
| |
| +---lib1.2.4
| | ten.js
...
The important is only what lies inside the folder of libraries (This is just a small fraction of them). And I need all the files in every folder. Most of them are js and some are css.
I have copied libraries into javascript folder in Bottle and I routed each of them by hand, but with no success. Like this:
#lib1 js
@bottle.route('../static/javascript/libraries/lib1/<filename:re:.*\.js>')
def send_lib1(filename):
return bottle.static_file(filename, root='../static/javascript/libraries/lib1')
I did this for all the files. However it still doesn't work. Does anyone have any solution? And maybe how can I simplify this so I don't have to write everything by hand.
ChatGPT suggested this:
@bottle.route('/static/javascript/<filepath:path>')
def send_javascript(filepath):
return bottle.static_file(filepath, root='./javascript')
But it doesn't work.