Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
from flask import Flask, render_template
|
2 |
-
import folium
|
3 |
-
|
4 |
-
app = Flask(__name__)
|
5 |
-
|
6 |
-
@app.route('/')
|
7 |
-
def index():
|
8 |
-
return render_template('index.html')
|
9 |
-
|
10 |
-
@app.route('/admin')
|
11 |
-
def admin():
|
12 |
-
# Create a map centered on Delhi
|
13 |
-
delhi_coordinates = [28.6139, 77.2090]
|
14 |
-
folium_map = folium.Map(location=delhi_coordinates, zoom_start=12)
|
15 |
-
|
16 |
-
# Add predefined markers in Delhi
|
17 |
-
markers = [
|
18 |
-
{"name": "India Gate", "coordinates": [28.6129, 77.2295]},
|
19 |
-
{"name": "Red Fort", "coordinates": [28.6562, 77.2410]},
|
20 |
-
{"name": "Qutub Minar", "coordinates": [28.5245, 77.1855]},
|
21 |
-
]
|
22 |
-
|
23 |
-
# Add markers to the map
|
24 |
-
for marker in markers:
|
25 |
-
folium.Marker(
|
26 |
-
location=marker["coordinates"],
|
27 |
-
popup=marker["name"],
|
28 |
-
icon=folium.Icon(color="blue", icon="info-sign"),
|
29 |
-
).add_to(folium_map)
|
30 |
-
|
31 |
-
# Use a valid Folium tile layer
|
32 |
-
folium.TileLayer('OpenStreetMap').add_to(folium_map)
|
33 |
-
|
34 |
-
# Add Layer Control for toggling between tile layers
|
35 |
-
folium.LayerControl().add_to(folium_map)
|
36 |
-
|
37 |
-
# Generate the map HTML
|
38 |
-
map_html = folium_map._repr_html_()
|
39 |
-
|
40 |
-
# Render the template with the map
|
41 |
-
return render_template('admin.html', map=map_html)
|
42 |
-
|
43 |
-
if __name__ == '__main__':
|
44 |
-
app.run(debug=True)
|
|
|
1 |
+
from flask import Flask, render_template
|
2 |
+
import folium
|
3 |
+
|
4 |
+
app = Flask(__name__)
|
5 |
+
|
6 |
+
@app.route('/')
|
7 |
+
def index():
|
8 |
+
return render_template('index.html')
|
9 |
+
|
10 |
+
@app.route('/admin')
|
11 |
+
def admin():
|
12 |
+
# Create a map centered on Delhi
|
13 |
+
delhi_coordinates = [28.6139, 77.2090]
|
14 |
+
folium_map = folium.Map(location=delhi_coordinates, zoom_start=12)
|
15 |
+
|
16 |
+
# Add predefined markers in Delhi
|
17 |
+
markers = [
|
18 |
+
{"name": "India Gate", "coordinates": [28.6129, 77.2295]},
|
19 |
+
{"name": "Red Fort", "coordinates": [28.6562, 77.2410]},
|
20 |
+
{"name": "Qutub Minar", "coordinates": [28.5245, 77.1855]},
|
21 |
+
]
|
22 |
+
|
23 |
+
# Add markers to the map
|
24 |
+
for marker in markers:
|
25 |
+
folium.Marker(
|
26 |
+
location=marker["coordinates"],
|
27 |
+
popup=marker["name"],
|
28 |
+
icon=folium.Icon(color="blue", icon="info-sign"),
|
29 |
+
).add_to(folium_map)
|
30 |
+
|
31 |
+
# Use a valid Folium tile layer
|
32 |
+
folium.TileLayer('OpenStreetMap').add_to(folium_map)
|
33 |
+
|
34 |
+
# Add Layer Control for toggling between tile layers
|
35 |
+
folium.LayerControl().add_to(folium_map)
|
36 |
+
|
37 |
+
# Generate the map HTML
|
38 |
+
map_html = folium_map._repr_html_()
|
39 |
+
|
40 |
+
# Render the template with the map
|
41 |
+
return render_template('admin.html', map=map_html)
|
42 |
+
|
43 |
+
if __name__ == '__main__':
|
44 |
+
app.run(host='0.0.0.0', port=7860, debug=True)
|