Skip to content

Latest commit

 

History

History
202 lines (153 loc) · 5.11 KB

File metadata and controls

202 lines (153 loc) · 5.11 KB

Location Question App

A FastAPI web application for posting questions tied to specific GPS locations with photo evidence. Mobile-only interface (works with rear camera capture).

Features

Mobile Detection – Shows warning on desktop devices
Interactive Map – Leaflet-based map with location search (Nominatim)
GPS Tracking – Real-time location with continuous geolocation
Camera Capture – Forces rear camera only (no gallery selection)
Question Posting – Post questions with photo, GPS coords, and timestamp
Location Pinning – Manually place pins on the map
Submission Storage – In-memory storage (can be extended to database)

Installation

1. Install dependencies

pip install -r app_requirements.txt

2. Run the app

python app.py

The app will start on http://0.0.0.0:8000

Usage

1. Access the app on mobile

Open your phone browser and navigate to:

http://<your-laptop-ip>:8000

Example: http://192.168.1.100:8000

💡 Find your IP:

  • Windows: Open PowerShell and run ipconfig (look for "IPv4 Address")
  • Mac/Linux: Run ifconfig

2. Allow permissions

The app will request:

  • Location permissions – GPS coordinates
  • Camera permissions – Photo capture (rear camera)

3. Use the app

  1. Map - Search for a location or let GPS track you
  2. Pin - Click "📌 Place Pin" to mark current location
  3. Question - Type your question
  4. Camera - Click "📷 Capture Photo" to take a picture (rear camera only)
  5. Post - Click "✈️ Post Question" to submit

API Endpoints

GET /

Serves the main app interface (HTML)

POST /submit

Submit a question with location and image

Request Body:

{
    "question": "What is this?",
    "latitude": 40.7128,
    "longitude": -74.0060,
    "timestamp": "2026-02-28T10:30:00Z",
    "imageBase64": "data:image/jpeg;base64,..."
}

Response:

{
    "status": "success",
    "message": "Question submitted!",
    "id": 1
}

GET /submissions

Get all submissions

GET /submission/{id}

Get a specific submission by ID

Mobile Requirements

  • Device: Smartphone or tablet
  • Browser: Chrome, Firefox, Safari (any modern mobile browser)
  • Permissions: GPS and Camera access
  • Camera: App forces rear-facing camera (facingMode: 'environment')

Desktop Access

If you open the app on a laptop/desktop:

⚠️ Mobile Device Required
This application only works on mobile devices.
Please open this link on your phone.

File Structure

e:\pinpoint\
├── app.py                    # FastAPI application
├── app_requirements.txt       # Python dependencies
├── templates/
│   └── index.html           # Main UI (HTML/CSS/JS)
└── README.md                # This file

Features Breakdown

1. Mobile Detection

function isMobileDevice() {
    return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}

2. Real-time Geolocation

Uses navigator.geolocation.watchPosition() for continuous GPS tracking

3. Camera Capture (Rear Only)

<input type="file" id="cameraInput" accept="image/*" capture="environment" />
  • capture="environment" forces rear camera (not front camera)
  • No gallery selection allowed

4. Map Integration

  • Leaflet for interactive mapping
  • Nominatim (OpenStreetMap) for location search
  • Custom markers for current location and pins

5. Data Storage

Currently uses in-memory storage. Can be extended with:

  • SQLite
  • PostgreSQL
  • MongoDB
  • Cloud storage (Firebase, etc.)

Example Response

{
    "id": 1,
    "question": "Why is this area flooded?",
    "latitude": 40.7128,
    "longitude": -74.0060,
    "timestamp": "2026-02-28T10:30:00Z",
    "imageBase64": "data:image/jpeg;base64,...",
    "submitted_at": "2026-02-28T10:31:45.123456"
}

Constraints & Limitations

⚠️ Desktop Only Shows Warning – No functionality on laptop
⚠️ Rear Camera Forced – Cannot select front camera or gallery
⚠️ HTTPS Recommended – Geolocation + Camera may require HTTPS in production
⚠️ In-Memory Storage – Data resets when server restarts

Future Enhancements

  • Persistent database storage
  • User authentication
  • Question threading/comments
  • Image classification using the Python scripts (1-6)
  • Map heat map of questions
  • Real-time notifications
  • Social media integration

Troubleshooting

"Apps can't access your location" (iPhone)

  1. Go to Settings → Privacy → Location Services
  2. Find the browser → Change to "While Using"
  3. Refresh the app

Camera not working

  1. Check browser permissions: Settings → Apps → Camera/Microphone
  2. Make sure you're using HTTPS (or localhost for testing)
  3. Try a different browser

Map not loading

  1. Check internet connection
  2. Verify Leaflet CDN is accessible
  3. Check browser console for errors (F12 → Console)

License

MIT License – Free to use and modify