Skip to content
View Tseg9's full-sized avatar

Block or report Tseg9

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Tseg9/README.md

const express = require('express'); const fetch = require('node-fetch'); const app = express(); const port = 3000;

// Replace with your ipinfo.io API token const IPINFO_TOKEN = 'YOUR_IPINFO_TOKEN';

app.get('/get-location', async (req, res) => { try { // Get the user's IP address from the request const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress; //Remove IPv6 prefix, if any const cleanIpAddress = ipAddress.replace(/^.*:/, '');

const response = await fetch(`https://ipinfo.io/${cleanIpAddress}?token=${IPINFO_TOKEN}`);

if (!response.ok) {
  throw new Error(`HTTP error! status: ${response.status}`);
}

const data = await response.json();
res.json(data);

} catch (error) { console.error('Error fetching IP geolocation:', error); res.status(500).json({ error: 'Failed to get location' }); } });

app.listen(port, () => { console.log(Server listening at http://localhost:${port}); });

/*onst myName(Hi, I'm @Tseg9) console.log(myName)

  • 👋 Hi, I’m @Tseg9
  • 👀 I’m interested in ...
  • 🌱 I’m currently learning ...
  • 💞️ I’m looking to collaborate on ...
  • 📫 How to reach me ...
  • 😄 Pronouns: ...
  • ⚡ Fun fact: ...

Popular repositories Loading

  1. Tseg9 Tseg9 Public

    Config files for my GitHub profile.

  2. Sara-web Sara-web Public template

    Sara web

    HTML

  3. Sarsweb Sarsweb Public

  4. Sars-web Sars-web Public

    HTML

  5. contact.github.io contact.github.io Public

    CSS

  6. sars3D sars3D Public