Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# API Keys Configuration
# Copy this file to .env and fill in your actual API keys

# OpenWeatherMap API (for weather and air quality data)
# Get your free API key from: https://openweathermap.org/api
OPENWEATHER_API_KEY=your_openweathermap_api_key_here

# Visual Crossing API (for monthly weather data)
# Get your free API key from: https://www.visualcrossing.com/weather-api
VISUALCROSSING_API_KEY=your_visualcrossing_api_key_here

# News API (for crime news)
# Get your free API key from: https://newsapi.org/
NEWS_API_KEY=your_news_api_key_here

# Google Custom Search API (for chatbot functionality)
# Get your API key from: https://developers.google.com/custom-search/v1/introduction
GOOGLE_API_KEY=your_google_api_key_here

# Google Custom Search Engine ID
# Create a custom search engine at: https://cse.google.com/
CSE_ID=your_custom_search_engine_id_here
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Environment variables
.env
.env.local
.env.*.local

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
ENV/
env.bak/
venv.bak/
.venv/

# Streamlit
.streamlit/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Logs
*.log

# Temporary files
*.tmp
*.temp

# API Keys and secrets (additional security)
config/secrets.py
secrets.json
47 changes: 44 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,51 @@ City Pulse is a sleek, real-time dashboard built with **Streamlit** that provide

---

## πŸ“¦ Installation
## πŸ“¦ Installation & Setup

### 1. Clone the Repository
```bash
git clone https://github.com/your-username/CITY-PULSE.git
cd CITY-PULSE
```

### 2. Install Dependencies
```bash
git clone https://github.com/your-username/city-pulse.git
cd city-pulse
pip install -r requirements.txt
```

### 3. Set Up Environment Variables
1. Copy the example environment file:
```bash
cp .env.example .env
```

2. Edit the `.env` file and add your API keys:
```bash
# Required API Keys
OPENWEATHER_API_KEY=your_openweathermap_api_key_here
VISUALCROSSING_API_KEY=your_visualcrossing_api_key_here
NEWS_API_KEY=your_news_api_key_here
GOOGLE_API_KEY=your_google_api_key_here
CSE_ID=your_custom_search_engine_id_here
```

### 4. Get Your API Keys
- **OpenWeatherMap API**: [Get free API key](https://openweathermap.org/api)
- **Visual Crossing API**: [Get free API key](https://www.visualcrossing.com/weather-api)
- **News API**: [Get free API key](https://newsapi.org/)
- **Google Custom Search API**: [Get API key](https://developers.google.com/custom-search/v1/introduction)
- **Custom Search Engine**: [Create CSE](https://cse.google.com/)

### 5. Run the Application
```bash
streamlit run app.py
```

---

## 🚨 Security Notice

This application requires API keys to function properly. **Never commit your `.env` file or expose your API keys publicly**. The `.env` file is already included in `.gitignore` to prevent accidental commits.

---
16 changes: 13 additions & 3 deletions utils/chatbot.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# utils/chatbot.py

import requests
import os
from dotenv import load_dotenv

# Replace these with env variables or config if you want
GOOGLE_API_KEY = "AIzaSyAIQcBW-1Wmx4Z8vuvyibvrum9dS0HgheI"
CSE_ID = "41a7d2bcb1d014824"
load_dotenv()

# Load API keys from environment variables
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
CSE_ID = os.getenv("CSE_ID")

# Validate that required environment variables are set
if not GOOGLE_API_KEY:
raise ValueError("Missing required environment variable: GOOGLE_API_KEY")
if not CSE_ID:
raise ValueError("Missing required environment variable: CSE_ID")

def search_google(query):
try:
Expand Down