Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
Flask js files not loading due to template folder and static folder file structure

So I'm trying to make a website where I'm able to just drag and drop folders containing HTML, js, and CSS files into a "library" directory and have those files served on my flask app. There's one big problem I haven't been able to get over. The problem is that all of these HTML files link to their respective js files using relative paths. For example:

<script src="js/keyboard_input_manager.js"></script>

and these files are 2 folders deep into my (combined) templates/static folder. I could fix this by doing

<script src="library/2048/js/keyboard_input_manager.js"></script>

but that is very tedious, especially when working with so many files.

TLDR: If I were to run my flask app and load a template, it wouldn't load any js or CSS because of relative paths.

Is there any way to go about this without individually changing each path to relate to the templates folder?

Example of my current filesystem:

-FLASK PROJECT
   |->library (templates/static folder)
   |    |->2048
   |       |->index.html, index.css, index.js
   |    |->Game2
   |       |->index.html, index.css, index.js
   |->main.py

What I've Tried:

  • Using Blueprint but I can't create a whole blueprint for every file?
  • Messing with paths of template folder and static folder

Flask Noob - Please let me know if I'm leaving out any helpful information :) Thanks

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda