This project is a Node.js web application that provides UV index and sun exposure safety suggestions based on user-supplied geographic coordinates (latitude and longitude). It uses the OpenUV API to fetch real-time UV data and gives recommendations on how long it is safe to stay outside, tailored for Indian users.
- User Input: Users enter their longitude and latitude via a web form.
- UV Data Fetching: The backend fetches the current UV index for the provided location using the OpenUV API.
- Safety Suggestions: Based on the UV index, the app suggests how long it is safe to stay outside.
- Simple UI: The frontend is rendered using EJS templates and styled with CSS, including a background image.
- API Key Security: Uses environment variables to keep the OpenUV API key secure.
- Backend: Node.js, Express
- Frontend: EJS (Embedded JavaScript templates), HTML, CSS
- Other Libraries: body-parser, dotenv
- API: OpenUV API
-
Clone the repository:
git clone <repo-url> cd UV-check-API-Project
-
Install dependencies:
npm install
-
Set up environment variables:
- Create a
.envfile in the root directory. - Add your OpenUV API key:
API_KEY=your_openuv_api_key_here
- Create a
-
Run the application:
node index.js
The app will be available at http://localhost:3000.
- Open the app in your browser.
- Enter your longitude and latitude.
- Submit the form to get the current UV index and a safety suggestion for sun exposure.
index.js- Main server file (Express app, routes, API logic)views/index.ejs- Main HTML template for the UIpublic/images/bg2.jpg- Background image for the UI.env- (Not committed) Store your API key here
- The
.envfile is ignored by git for security. - Make sure you have a valid OpenUV API key. You can get one from OpenUV.
- The app is tailored for Indian users but can be adapted for other regions.