added frontend and script examples
This commit is contained in:
parent
368c4de6fe
commit
61b10a2bc2
6 changed files with 385 additions and 0 deletions
53
README.md
53
README.md
|
@ -101,6 +101,59 @@ Response:
|
|||
- CSV files: Must have a header row with column names
|
||||
- JSON files: Must contain valid JSON data
|
||||
|
||||
## Using the API in External Applications
|
||||
|
||||
### Python Example
|
||||
|
||||
Here's how to consume the API data in a Python script:
|
||||
|
||||
```python
|
||||
import requests
|
||||
import pandas as pd
|
||||
from pprint import pprint
|
||||
|
||||
# Base URL of the API
|
||||
API_BASE_URL = 'http://localhost:8000'
|
||||
|
||||
# Example 1: Get users data
|
||||
response = requests.get(f"{API_BASE_URL}/api/users")
|
||||
users_data = response.json()
|
||||
pprint(users_data)
|
||||
|
||||
# Example 2: Get contacts and convert to DataFrame
|
||||
response = requests.get(f"{API_BASE_URL}/api/contacts")
|
||||
contacts_data = response.json()
|
||||
contacts_df = pd.DataFrame(contacts_data)
|
||||
print(contacts_df)
|
||||
|
||||
# Example 3: Extract specific information
|
||||
contacts_response = requests.get(f"{API_BASE_URL}/api/contacts")
|
||||
contacts = contacts_response.json()
|
||||
locations = [contact['location'] for contact in contacts]
|
||||
print(f"Available locations: {locations}")
|
||||
|
||||
# Example 4: Filtering data
|
||||
users_response = requests.get(f"{API_BASE_URL}/api/users")
|
||||
users_data = users_response.json()
|
||||
filtered_users = [user for user in users_data.get('users', [])
|
||||
if user.get('name') == 'John']
|
||||
print(f"Filtered users: {filtered_users}")
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
{'users': [{'name': 'John', 'email': 'john@example.com'},
|
||||
{'name': 'Jane', 'email': 'jane@example.com'}]}
|
||||
|
||||
location contact
|
||||
0 dortmund achim
|
||||
1 madrid santos
|
||||
|
||||
Available locations: ['dortmund', 'madrid']
|
||||
|
||||
Filtered users: [{'name': 'John', 'email': 'john@example.com'}]
|
||||
```
|
||||
|
||||
## Manual Container Setup
|
||||
|
||||
### Docker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue