A real-time location sharing web app built with FastAPI, WebSockets (python-socketio), Leaflet.js, and the OSRM routing engine. Supports live location broadcasting between multiple users with route rendering on an interactive map.
- Live location sharing via WebSockets using python-socketio
- Interactive map powered by Leaflet.js with OpenStreetMap tiles
- Route rendering between users via the OSRM public routing API
- Multi-user session support
- Public tunnel support via Cloudflare Tunnel (
cloudflared) - Deployed on Render
osrm/
├── backend/ # FastAPI + socketio server logic
├── frontend/ # Leaflet.js map UI (HTML/JS)
├── map-files/ # OSRM map data or config files
├── void/ # Additional module / experimental code
├── .env # Environment variables
├── .gitignore
├── Procfile # Render deployment entry point
├── cloudflared.exe # Cloudflare Tunnel binary for public URL
└── requirements.txt # Python dependencies
- Backend: FastAPI, python-socketio, Uvicorn, httpx
- Frontend: Vanilla JS, Leaflet.js, OpenStreetMap
- Routing: OSRM (Open Source Routing Machine) public API
- Tunneling: Cloudflare Tunnel (
cloudflared) - Deployment: Render
- Python 3.10+
- pip
git clone https://github.com/MKarthik730/osrm.git
cd osrm
pip install -r requirements.txtCopy .env and fill in any required values:
cp .env .env.localuvicorn main:socket_app --host 0.0.0.0 --port 8000 --reloadOpen http://localhost:8000 in your browser and allow location access.
./cloudflared.exe tunnel --url http://localhost:8000Share the generated *.trycloudflare.com URL with others to start a live session.
- User opens the app in a browser and grants location permission.
- The browser sends GPS coordinates to the FastAPI backend over a WebSocket (python-socketio).
- The server broadcasts updated coordinates to all connected clients in the session.
- Each client plots other users as markers on the Leaflet map.
- The OSRM API computes the road route between two points and draws it as a polyline overlay.
The Procfile defines the start command:
web: uvicorn main:socket_app --host 0.0.0.0 --port $PORT
Push to main and Render will auto-deploy.
fastapi
uvicorn
python-socketio
httpx
python-multipart
- OSRM — Open Source Routing Machine
- Leaflet.js — Interactive maps
- OpenStreetMap — Map tile data
- Cloudflare Tunnel — Public URL tunneling