May 7, 2026

Python server to run html with Node.js script

 to run Python server in cmd window,

python -m http.server 8000


in web browser,

http://localhost:8000/index.html


If it does not work, 

(1) install Node.js

(2) in cmd window:

    npm create vite@latest  temp  -- --template react

(3) in temp folder in cmd window:

    npm install

    npm run dev

(4) replace the generated src/App.jsx with your file contents and import your CSS in the component or main.jsx

(5) in cmd window, build:

    npm run build

(6) copy all files in the "dist" folder, and now the Python server will work


May 8, 2025

[Windows] add current folder to PATH

 To add current folder/directory to PATH environment,

in cmd windows,

    set PATH=%PATH%;%CD%



Jun 5, 2024

[QGIS] link Google maps to QGIS

To link Google maps to QGIS,

mouse-right-click on XYZ tiles --> new connection


Google roadmap

http://mt0.google.com/vt/lyrs=r&hl=en&x={x}&y={y}&z={z}


Google terrain

http://mt0.google.com/vt/lyrs=p&hl=en&x={x}&y={y}&z={z}


Google satellite 

http://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}


Google satellite Hybrid

http://mt0.google.com/vt/lyrs=y&hl=en&x={x}&y={y}&z={z}



Mar 7, 2024

install and use Jupyter notebook for Python

In cmd window,

To install,

        python -m pip install notebook


To use,

        jupyter notebook



Nov 15, 2023

make a Python code executable (.exe)

Method 1.

python -m pip install pyinstaller

python -m PyInstaller --noconfirm --onefile --windowed  code.py



Method 2.

python -m pip install auto-py-to-exe

python -m auto_py_to_exe



adjust column lengths when using Pandas ExcelWriter

 To dynamically adjust all the column lengths,

        writer = pd.ExcelWriter('temp.xlsx') 

        df.to_excel(writer, sheet_name='sheetName', index=False)

        for column in df:

                column_length = max(df[column].astype(str).map(len).max(), len(column))

                col_idx = df.columns.get_loc(column)

                writer.sheets['sheetName'].set_column(col_idx, col_idx, column_length)

        writer.close()



To manually adjust a column using column name,

        col_idx = df.columns.get_loc('columnName')

        writer.sheets['sheetName'].set_column(col_idx, col_idx, 20)



To manually adjust a column using column index,

        writer.sheets['sheetName'].set_column(col_idx, col_idx, 20)



Potential error messages:

        AttributeError: 'Worksheet' object has no attribute 'set_column'

-->  install "xlsxwriter" module

-->  use the installed as the engine,  writer = pd.ExcelWriter('temp.xlsx', engine='xlsxwriter') 


remove "FutureWarning" messages in Python programs

We can remove "FutureWarning" messages in Python programs by adding:

        import warnings 

        warnings.simplefilter(action='ignore', category=FutureWarning)