Python-Postman Here's a README file for your Flask application:
This is a simple Flask application that demonstrates basic routing and HTTP methods. The application has several endpoints that return text based on the provided routes and parameters. The app also allows you to update a stored age value using a POST request.
To run this application, you'll need:
- Python installed (version 3.x recommended)
- Flask installed (
pip install flask
)
-
Clone the repository or create a file with the provided Flask code.
-
Install Flask if you haven't already:
pip install flask
-
Run the application:
python <your_filename>.py
Replace
<your_filename>
with the name of the file containing the Flask code. -
The application will start on
http://127.0.0.1:5000/
.
- Description: Returns a simple greeting.
- Example:
curl http://127.0.0.1:5000/
- Response:
Hello world!
- Description: Returns a message including the stored age.
- Example:
curl http://127.0.0.1:5000/sheela
- Response:
Sheela ki jawan 26!
- Description: Takes an age as a URL parameter and returns a message with that age.
- Example:
curl http://127.0.0.1:5000/sheela/30
- Response:
Sheela ki age 30.
-
Description: Updates the stored age value using a form parameter and returns a confirmation.
-
Example (using Postman or
curl
):curl -X POST -F "age=30" http://127.0.0.1:5000/sheela
-
Response:
DONE
Note: The function currently does not properly update the
stored_age
due to incorrect placement of theglobal
keyword and logic in the function.
-
GET Requests:
- Open Postman and create a new GET request to
http://127.0.0.1:5000/
to test the root endpoint. - Create another GET request to
http://127.0.0.1:5000/sheela
to see the stored age. - Test dynamic age using
http://127.0.0.1:5000/sheela/30
.
- Open Postman and create a new GET request to
-
POST Requests:
- Open Postman and create a new POST request to
http://127.0.0.1:5000/sheela
. - Under the "Body" tab, select "form-data" and add a key-value pair with
key = age
andvalue = <your_desired_age>
. - Click "Send" to see the response.
- Open Postman and create a new POST request to
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to modify the README to better suit your needs or to add more information about your application!