Python Classroom notes 03/Aug/2026

Web Programming

  • Here we have two problems to solve

    • Web serving html pages => Web APP
      • Frameworks: Django
    • Web serving data/actions/method => APIs
      • Frameworks:
        • FastAPI
        • Flask
        • Django-restful
  • our focus: APIs with FastAPI

Lets use a calculator which is hosted as api

  • Instructions to run an api server on your system
git clone https://github.com/asquarezone/Python.git
cd Python/Aug26/WebAPIs/using_apis/calc
python -m venv .venv
.venv/Scripts/activate
# source .venv/bin/activate
pip install -r requirements.txt
#python main.py
fastapi dev main.py
  • Naviagate to http://127.0.0.1:8000/docs

  • This api has add, sub, mul, div

  • access add http://127.0.0.1/add?a=3&b=5

    • url: http://127.0.0.1/add
    • parameters:
      • query string: starts with ?<name1>=<value1>&<name2>=<value2>&
  • Install postman app and use as it is recommened in the class

  • Lets write a client in python which does this

  • Create a new virtual environment

  • Create a file called as calc_client.py
  • Refer Here for changes done

Lets use some existing apis

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading