0% found this document useful (0 votes)
13 views2 pages

Python Setup and Demo

This document outlines the steps to set up a Python environment for interacting with a Spring Boot API. It includes instructions for installing Python, pip, required libraries, and creating a Python script to make API calls. Additional notes on running the Spring Boot application and using virtual environments are also provided.

Uploaded by

kintaro120988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Python Setup and Demo

This document outlines the steps to set up a Python environment for interacting with a Spring Boot API. It includes instructions for installing Python, pip, required libraries, and creating a Python script to make API calls. Additional notes on running the Spring Boot application and using virtual environments are also provided.

Uploaded by

kintaro120988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# Python Environment Setup Steps for Interacting with Spring Boot API

## Step 1: Install Python


1. Download Python (version 3.8 or higher recommended) from the official website:
https://www.python.org/downloads/
2. Run the installer:
- Ensure "Add Python to PATH" is checked during installation.
- Select "Customize installation" to include pip (Python package manager) if
needed.
3. Verify installation by opening a terminal (Command Prompt, PowerShell, or
Terminal) and running:
```
python --version
```
You should see the installed Python version (e.g., Python 3.10.0).

## Step 2: Install pip (if not included)


1. Download get-pip.py from https://bootstrap.pypa.io/get-pip.py
2. Run the following command in the terminal:
```
python get-pip.py
```
3. Verify pip installation:
```
pip --version
```

## Step 3: Install Required Python Libraries


1. Install the `requests` library to make HTTP calls to the Spring Boot API:
```
pip install requests
```
2. Verify installation:
```
pip show requests
```

## Step 4: Create and Run a Python Script to Interact with Spring Boot
1. Create a file named `spring_boot_client.py` with the following code:
```python
import requests

def call_spring_boot_api(name="World"):
url = f"http://localhost:8080/greet?name={name}"
try:
response = requests.get(url)
if response.status_code == 200:
print(f"API Response: {response.text}")
else:
print(f"Error: Received status code {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"Error connecting to API: {e}")

if __name__ == "__main__":
call_spring_boot_api("Alice")
```
2. Ensure the Spring Boot application (from the previous demo) is running on
`http://localhost:8080`.
3. Run the Python script:
```
python spring_boot_client.py
```
Expected output: `API Response: Hello, Alice!`

## Step 5: Additional Notes


- Ensure the Spring Boot application is running before executing the Python script.
- If you encounter SSL or network issues, check your firewall settings or ensure
the API is accessible.
- To install additional Python libraries for further development (e.g., `pandas`,
`flask`), use:
```
pip install <library_name>
```
- For a virtual environment (recommended):
1. Create a virtual environment:
```
python -m venv venv
```
2. Activate it:
- Windows: `venv\Scripts\activate`
- macOS/Linux: `source venv/bin/activate`
3. Install libraries within the virtual environment.

You might also like