This repository contains tasks that I have worked on during HPDF Week 1
- Clone the repository
git clone https://github.com/ashwani99/hpdf-tasks
- Create a virtual environment and activate it. We will be setting Python 3 as default in the virtual environment. Although this step is not mandatory but it is recommended so that the development environment is isolated.
virtualenv venv --python=`which python3`
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Run the application within the devserver provided by flask
cd hpdf-tasks/
python run.py
- All set. Fire up any web browser and go to
http://127.0.0.1:5000/
to see the application live!
These tasks consists of implementation of multiple endpoints which serve different needs. The following tasks are are accomplished.
- Add an endpoint at
/
that displaysHello World
along with your first name (and slack username) - Add and endpoint at
/authors
which fetches a list of authors and count of their posts using the given JSON data available via URLs https://jsonplaceholder.typicode.com/users and https://jsonplaceholder.typicode.com/posts - Add an endpoint at
/setcookie
which sets a cookie with valuesname=<your-first-name>
andage=<your-age
if not set already. - Add an endpoint at
/getcookies
which displays the values of the cookie that has been set with/setcookie
endpoint. - Deny request to
/robots.txt
endpoint with 403 (Forbidden) status code. - Add an endpoint at
/html
displaying some placeholder HTML text. Lorem Ipsum was used here. - Display a form containing a textbox at
/input
endpoint. - Upon submitting the form at
/input
, send the data via aPOST
request to/input
endpoint. This/input
endpoint should display the text data received via the request instead of the form. Also log the received data to STDOUT.
- Python 3.x
- Flask
MIT