Skip to content

Commit 251c637

Browse files
tybalexthedadams
authored andcommitted
minor fix, not going to assert status code any more
1 parent 0017c5e commit 251c637

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

wordpress/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ services:
1717
WORDPRESS_DB_USER: dbuser
1818
WORDPRESS_DB_PASSWORD: dbpassword
1919
WORDPRESS_DB_NAME: exampledb
20+
WORDPRESS_CONFIG_EXTRA: |
21+
define('WP_ENVIRONMENT_TYPE', 'local');
2022
volumes:
2123
- wordpress:/var/www/html
2224

@@ -38,7 +40,11 @@ volumes:
3840
```
3941
and run `docker compose -f wordpress.yaml up`.
4042

43+
Navigate to localhost:8070. The first time you run the container, it will prompt you to register the site name and create a new user.
44+
4145
### CRITICAL: Configure Permalinks in Settings
42-
Without configuring permalinks, the Wordpress API will not work, because the `/wp-json` endpoint will not be available.
46+
1. Without configuring permalinks, the Wordpress API will not work, because the `/wp-json` endpoint will not be available.
4347
To do this, go to your wordpress site dashboard, on the left sidebar, select `Settings` -> `Permalinks`, then select any non-plain Permalink structure.
48+
2. You must create an application password to be able to create posts.
49+
To do this, go to your wordpress site dashboard, on the left sidebar, select `Users`, edit your user profile and scroll down to the `Application Passwords` section, then select `Add New`.
4450

wordpress/tool.gpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Name: Wordpress
3-
Description: Tools for interacting with User's self-hosted WordPress Site
3+
Description: Tools for interacting with self-hosted and hosted Wordpress sites that support basic auth.
44
Metadata: bundle: true
55
Share Tools: List Users, Get User, List Posts, Retrieve Post, Create Post, Update Post, Delete Post, Get Site Settings
66

wordpress/tools/posts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def list_posts(client):
142142
url += suffix
143143

144144
response = client.get(url)
145-
if response.status_code == 200:
145+
if response.status_code >= 200 and response.status_code < 300:
146146
return [_format_posts_response(post) for post in response.json()]
147147
else:
148148
print(f"Failed to list posts. Error: {response.status_code}, {response.text}")
@@ -234,7 +234,7 @@ def create_post(client):
234234
post_data["ping_status"] = ping_status
235235

236236
response = client.post(url, json=post_data)
237-
if response.status_code == 201:
237+
if response.status_code >= 200 and response.status_code < 300:
238238
return _format_posts_response(response.json())
239239
else:
240240
print(f"Failed to create post. Error: {response.status_code}, {response.text}")
@@ -249,7 +249,7 @@ def delete_post(client):
249249
url += "?force=true"
250250

251251
response = client.delete(url)
252-
if response.status_code == 200:
252+
if response.status_code >= 200 and response.status_code < 300:
253253
return {"message": "Post deleted successfully"}
254254
else:
255255
print(f"Failed to delete post. Error: {response.status_code}, {response.text}")
@@ -350,7 +350,7 @@ def update_post(client):
350350
post_data["ping_status"] = ping_status
351351

352352
response = client.post(url, json=post_data)
353-
if response.status_code == 200:
353+
if response.status_code >= 200 and response.status_code < 300:
354354
return _format_posts_response(response.json())
355355
else:
356356
print(f"Failed to update post. Error: {response.status_code}, {response.text}")

wordpress/tools/site.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
def get_site_settings(client):
66
url = f"{WORDPRESS_API_URL}/settings"
77
response = client.get(url)
8-
if response.status_code == 200:
8+
if response.status_code >= 200 and response.status_code < 300:
99
return response.json()
1010
else:
1111
print(f"Error: {response.status_code}, {response.text}")

wordpress/tools/users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_user(client):
1212
user_id = os.environ["USER_ID"]
1313
url = f"{WORDPRESS_API_URL}/users/{user_id}"
1414
response = client.get(url)
15-
if response.status_code == 200:
15+
if response.status_code >= 200 and response.status_code < 300:
1616
return _format_users_response(response.json())
1717
else:
1818
print(f"Error: {response.status_code}, {response.text}")
@@ -22,7 +22,7 @@ def get_user(client):
2222
def list_users(client):
2323
url = f"{WORDPRESS_API_URL}/users"
2424
response = client.get(url)
25-
if response.status_code == 200:
25+
if response.status_code >= 200 and response.status_code < 300:
2626
return [_format_users_response(user) for user in response.json()]
2727
else:
2828
print(f"Error: {response.status_code}, {response.text}")

0 commit comments

Comments
 (0)