|
1 | | ---- server.py 2026-01-06 20:27:13 |
2 | | -+++ server.py 2026-01-06 20:32:16 |
3 | | -@@ -6,6 +6,10 @@ |
| 1 | +diff --git c/server.py w/server.py |
| 2 | +index 06d208d..6304e07 100644 |
| 3 | +--- c/server.py |
| 4 | ++++ w/server.py |
| 5 | +@@ -7,6 +7,10 @@ app = Flask(__name__) |
4 | 6 | PORT = 3000 |
5 | 7 |
|
6 | 8 |
|
|
11 | 13 | @app.route('/api/weather-activity', methods=['GET']) |
12 | 14 | def weather_activity(): |
13 | 15 | """Get location from IP, weather, and activity recommendations""" |
14 | | -@@ -29,6 +33,8 @@ |
| 16 | +@@ -30,6 +34,8 @@ def weather_activity(): |
15 | 17 | weather_response.raise_for_status() |
16 | 18 | weather = weather_response.json()['current_weather'] |
17 | 19 |
|
|
20 | 22 | # Business logic: Recommend activity based on weather |
21 | 23 | recommended_activity = 'Play a board game' |
22 | 24 | if weather['temperature'] > 40: |
23 | | -@@ -95,31 +101,18 @@ |
| 25 | +@@ -96,20 +102,18 @@ def create_user(): |
24 | 26 | return jsonify({'error': 'Failed to create user'}), 500 |
25 | 27 |
|
26 | 28 |
|
|
34 | 36 | def get_post(post_id): |
35 | 37 | """Get post with comments""" |
36 | 38 | try: |
37 | | -- # Fetch post and comments in parallel using requests |
38 | | -- import concurrent.futures |
| 39 | +- post_response = requests.get(f'https://jsonplaceholder.typicode.com/posts/{post_id}') |
| 40 | +- post_response.raise_for_status() |
39 | 41 | - |
40 | | -- with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: |
41 | | -- post_future = executor.submit( |
42 | | -- requests.get, f'https://jsonplaceholder.typicode.com/posts/{post_id}' |
43 | | -- ) |
44 | | -- comments_future = executor.submit( |
45 | | -- requests.get, f'https://jsonplaceholder.typicode.com/posts/{post_id}/comments' |
46 | | -- ) |
47 | | -- |
48 | | -- post_response = post_future.result() |
49 | | -- comments_response = comments_future.result() |
50 | | -- |
51 | | -- post_response.raise_for_status() |
52 | | -- comments_response.raise_for_status() |
| 42 | +- comments_response = requests.get(f'https://jsonplaceholder.typicode.com/posts/{post_id}/comments') |
| 43 | +- comments_response.raise_for_status() |
53 | 44 | - |
54 | 45 | - return jsonify({ |
55 | 46 | - 'post': post_response.json(), |
|
0 commit comments