0
votes

The code below tries to read in my leaflet.js and leaflet.css files which are stored in static/leaflet/package/dist/

The static folder is in the same directory as my flask app.py code. Templates are in a templates folder. The below code is from my home.html template.

For some reason if I use a url source for my leaflet.js and leaflet.css codes, the map works perfectly. Once I try to source my scripts from a directory, my map breaks. I think it is because I am not properly integrating my url_for. It may be also further messed up because I am using template inheritance.

Thanks in advance for any help!!

{% extends "base.html" %}

{% block header %}
<link rel="stylesheet" href="{{url_for('static', filename='leaflet/package/dist/leaflet.css')}}">
<script src="{{url_for('static', filename='leafleat/package/dist/leaflet.js')}}"></script>
<style>
    #map{ width: 100%; height: 100%; }
</style>
{% endblock %}

edit:

These are the HTTP status codes I get back from my server. Which make it look like the only thing not being obtained is my leaflet.js script.

127.0.0.1 - - [04/Oct/2019 16:17:01] "GET / HTTP/1.1" 200 -

127.0.0.1 - - [04/Oct/2019 16:17:01] "GET /static/leaflet/package/dist/leaflet.css HTTP/1.1" 200 -

127.0.0.1 - - [04/Oct/2019 16:17:01] "GET /static/leafleat/package/dist/leaflet.js HTTP/1.1" 404 -

127.0.0.1 - - [04/Oct/2019 16:17:01] "GET /static/favicon.ico HTTP/1.1" 200 -

1

1 Answers

0
votes

Fixed it. I misspelled leaflet in the leaflet.js line. Leaving this up in case anyone needs help with leaflet and flask at any point.