Local Network Setup: Windows - Android Hotspot & Python Web Server by t.me/Nexiuo

A guide focusing on connecting a Windows device to an Android hotspot without internet access and setting up a local web server using Python's built-in HTTP server. By following these steps, you'll be able to find your Android device's IP address and set up a local web server that can be accessed from your Windows device connected to the same hotspot.


Getting the IP Address using Termux

  1. Install Termux: If you haven't already, download and install Termux from the Google Play Store.
  2. Open Termux: Launch the Termux app on your Android device.
  3. Update Termux Packages: Ensure all packages are up to date by running:
    pkg update && pkg upgrade
    
  4. Install net-tools: This package includes ifconfig, which helps in finding the IP address.
    pkg install net-tools
    
  5. Find the IP Address: Use ifconfig to find the IP address of your Android device.
    ifconfig
    
    Look for the wlan0 interface (or similar) and note the inet address, which is your device's IP address on the local network.
    example:
    ifconfig
    
    Warning: cannot open /proc/net/dev (Permission denied). Limited output.
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
    
    v4-seth_lte0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1472
            inet 192.0.0.4  netmask 255.255.255.255  destination 192.0.0.4
            unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
    
    wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.217.16  netmask 255.255.255.0  broadcast 192.168.217.255
            unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
    

Setting Up a Local Web Server Using Python's http.server

  1. Install Python: If Python isn't already installed on your Android device, you can install it via Termux.
    pkg install python
    
  2. Navigate to Your Desired Directory: Use the cd command to navigate to the directory where you want to serve files.
    cd /path/to/your/directory
    
  3. Start the HTTP Server: Run the following command to start a simple HTTP server on port 8000 (or any other port you prefer).
    python -m http.server 8000
    
    This will start the server, and you can access it from your Windows device by navigating to http://<Android_IP>:8000 in a web browser.

Example Commands

  • Get IP Address:
    ifconfig
    
  • Start HTTP Server:
    python -m http.server 8000
    

Steps to Connect Windows to Android Hotspot Without Internet

1. Verify Hotspot IP Address

  1. Check Android Hotspot IP:
    • On your Android device, go to Settings > Network & Internet > Hotspot & tethering > Wi-Fi hotspot.
    • Note the IP address of the hotspot. Typically, it is 192.168.43.1.

2. Connect Windows Device to Android Hotspot

  1. Connect to Hotspot:
    • On your Windows device, go to Settings > Network & Internet > Wi-Fi.
    • Find and connect to the SSID of your Android hotspot.

3. Disable Metered Connection

  1. Disable Metered Connection:
    • Go to Settings > Network & Internet > Wi-Fi.
    • Click on Manage known networks.
    • Select your Android hotspot SSID and click Properties.
    • Toggle Set as metered connection to Off.

4. Configure Static IP Address on Windows

  1. Set Static IP:
    • Go to Settings > Network & Internet > Wi-Fi.
    • Click on your connected network (Android hotspot).
      Click on your connected network (Android hotspot).
    • Scroll down to IP settings and click Edit.
    • Change from Automatic (DHCP) to Manual.
    • Toggle IPv4 to On and enter the following details:
    • IP address: An IP address in the same subnet as your Android device, e.g., 192.168.43.20.
    • Subnet prefix length: 24.
    • Gateway: The IP address of your Android device, e.g., 192.168.43.1.
    • Preferred DNS: 8.8.8.8 (or any other DNS server).
    • Click Save.
      How IT SHOULD LOOK

5. Disable Network Health Check

  1. Disable Active Probing:
    • Press Win + R, type regedit, and press Enter.
    • Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet.
    • Double-click EnableActiveProbing and change the value from 1 to 0.
    • Click OK and restart your computer.

Setting Up a Local Web Server Using Python

1. Install Python

  1. Download and Install Python:
    • Download the latest version of Python from python.org.
    • Follow the installation instructions, ensuring you add Python to your system PATH.

2. Start the Python HTTP Server

  1. Open Command Prompt:
    • Press Win + R, type cmd, and press Enter.
  2. Navigate to the Directory:
    • Use the cd command to navigate to the directory you want to serve. For example:
      cd C:\path\to\your\directory
      
  3. Start the Server:
    • Run the following command to start the Python HTTP server:
      python -m http.server 8000
      
    • This will start a simple HTTP server on port 8000.

3. Access the Local Web Server

  1. Access from Windows Device:
    • Open a web browser on your Windows device and navigate to http://localhost:8000 or http://<your-static-ip>:8000 (e.g., http://192.168.43.20:8000).
  2. Access from Other Devices:
    • Ensure other devices are connected to the same Android hotspot.
    • Open a web browser on any connected device and navigate to http://<your-static-ip>:8000 (e.g., http://192.168.43.20:8000).

By following these steps, you can establish a stable connection between your Windows device and the Android hotspot, and set up a local web server using Python's built-in HTTP server. This setup allows you to host and access web content on your local network without the need for an internet connection.

Edit

Pub: 06 Jul 2024 06:32 UTC

Edit: 06 Jul 2024 06:53 UTC

Views: 283