A single endpoint web API to search for Australian postcodes based on locality aka suburb.
https://www.matthewproctor.com/Content/postcodes/australian_postcodes.json
This web API uses only locality
, state
and postcode
fields.
-
Swagger UI Documentation: https://web-production-ed7a.up.railway.app/api/v0/ui .
-
Endpoint API:
web-production-ed7a.up.railway.app/api/v0/aust-postcode/
.
E.g. To search for localities which containspring
: https://web-production-ed7a.up.railway.app/api/v0/aust-postcode/spring .
This revision uses SQLite database file. Clone with:
git clone -b v0.0.1 https://github.com/behai-nguyen/bh_aust_postcode.git
Latest revision only works with PostgreSQL database.
Project directory is F:\bh_aust_postcode\
.
Create the virtual environment venv:
F:\bh_aust_postcode>C:\PF\Python310\Scripts\virtualenv.exe venv
To activate virtual environment venv:
F:\bh_aust_postcode>venv\Scripts\activate
Editable install project:
(venv) F:\bh_aust_postcode>venv\Scripts\pip.exe install -e .
Download postcodes and write to SQLite database file:
(venv) F:\bh_aust_postcode>venv\Scripts\flask.exe update-postcode
Run the development web server:
(venv) F:\bh_aust_postcode>venv\Scripts\flask.exe run
The Swagger UI URL on localhost:
http://localhost:5000/api/v0/ui
To search for postcodes whom locality contains the string spring
:
http://localhost:5000/api/v0/aust-postcode/spring
Project directory is /home/behai/webwork/bh_aust_postcode
:
behai@HP-Pavilion-15:~/webwork/bh_aust_postcode$ pwd
Output:
/home/behai/webwork/bh_aust_postcode
Create the virtual environment venv:
behai@HP-Pavilion-15:~/webwork/bh_aust_postcode$ virtualenv venv
To activate virtual environment venv:
behai@HP-Pavilion-15:~/webwork/bh_aust_postcode$ source venv/bin/activate
Editable install project:
(venv) behai@HP-Pavilion-15:~/webwork/bh_aust_postcode$ venv/bin/pip install -e .
For tag v0.0.1
, install gunicorn
separately:
(venv) behai@HP-Pavilion-15:~/webwork/bh_aust_postcode$ venv/bin/pip install gunicorn
Later revisions have gunicorn
installed as part of editable install.
Download postcodes and write to SQLite database file:
(venv) behai@HP-Pavilion-15:~/webwork/bh_aust_postcode$ venv/bin/flask update-postcode
Run the web server via gunicorn
:
(venv) behai@HP-Pavilion-15:~/webwork/bh_aust_postcode$ venv/bin/gunicorn --bind 0.0.0.0:5000 wsgi:app
The Swagger UI URL, accessed from Windows 10:
http://hp-pavilion-15:5000/api/v0/ui
To search for postcodes whom locality contains the string spring
:
http://hp-pavilion-15:5000/api/v0/aust-postcode/spring
There is nothing secured about this project 😂:
Works with SQLite:
SECRET_KEY=">s3g;?uV^K=`!(3.#ms_cdfy<c4ty%"
FLASK_APP=app.py
FLASK_DEBUG=True
# SOURCE_POSTCODE_URL="https://www.matthewproctor.com/Content/postcodes/australian_postcodes.json"
SOURCE_POSTCODE_URL="http://localhost/work/australian_postcodes.json"
SCHEMA="schema.sql"
DATABASE="australian_postcode.db"
Works with PostgreSQL:
SECRET_KEY=">s3g;?uV^K=`!(3.#ms_cdfy<c4ty%"
FLASK_APP=app.py
FLASK_DEBUG=True
# SOURCE_POSTCODE_URL="https://www.matthewproctor.com/Content/postcodes/australian_postcodes.json"
# SOURCE_POSTCODE_URL="http://192.168.0.17/australian_postcodes.json"
SOURCE_POSTCODE_URL="http://localhost/work/australian_postcodes.json"
KEEP_DOWNLOADED_POSTCODES=False
DB_CREATE_SCRIPT="schema.sql"
SCHEMA_NAME='bh_aust_postcode'
POSTCODE_TABLE_NAME='postcode'
PGHOST=localhost
PGDATABASE=ompdev
PGUSER=postgres
PGPASSWORD=pcb.2176310315865259
PGPORT=5432
A jQuery plugin which enables searching for Australian postcodes based on locality aka suburb.
Repo: https://github.com/behai-nguyen/bh-aust-postcode/tree/main/jquery-bhaustpostcode