Spaces:
Sleeping
Sleeping
| from flask import Flask, render_template | |
| import folium | |
| app = Flask(__name__) | |
| def index(): | |
| return render_template('index.html') | |
| def admin(): | |
| # Create a map centered on Delhi | |
| delhi_coordinates = [28.6139, 77.2090] | |
| folium_map = folium.Map(location=delhi_coordinates, zoom_start=12) | |
| # Add predefined markers in Delhi | |
| markers = [ | |
| {"name": "India Gate", "coordinates": [28.6129, 77.2295]}, | |
| {"name": "Red Fort", "coordinates": [28.6562, 77.2410]}, | |
| {"name": "Qutub Minar", "coordinates": [28.5245, 77.1855]}, | |
| ] | |
| # Add markers to the map | |
| for marker in markers: | |
| folium.Marker( | |
| location=marker["coordinates"], | |
| popup=marker["name"], | |
| icon=folium.Icon(color="blue", icon="info-sign"), | |
| ).add_to(folium_map) | |
| # Use a valid Folium tile layer | |
| folium.TileLayer('OpenStreetMap').add_to(folium_map) | |
| # Add Layer Control for toggling between tile layers | |
| folium.LayerControl().add_to(folium_map) | |
| # Generate the map HTML | |
| map_html = folium_map._repr_html_() | |
| # Render the template with the map | |
| return render_template('admin.html', map=map_html) | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860, debug=True) | |