Better Json Handling And Python Changes
Website and API
Here’s what changed today on rusty-forms.com:
- (1) The form redirect url is now optional
Previously you had to enter a redirect url but some forms don’t need these at all, so having to enter it seemed unnecessary.
- (2) Form submissions in JSON format will no longer redirect to the redirect url
Usually form submissions in JSON format come from API backends, or scripts, and a redirection may lead to unwanted behaviour. Other formats like application/x-www-form-urlencoded
will still redirect to the redirect url.
Redirect
1
2
3
4
5
6
7
8
9
10
11
12
13
curl -X POST \
-d "email=your-email@gmail.com" \
-d "name=Mike" \
-d "message=Hi, I want to enquire about ...." \
-d "products[]=Product A" \
-d "products[]=Product B" \
https://rusty-forms.com/v1/digest/821f4a10-127c-46c6-bc80-8790d219575a -v
...
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 302 Found
< location: https://rusty-forms.com
JSON, no redirect
1
2
3
4
5
6
7
8
9
curl -X POST \
-H "Content-Type: application/json" \
-d '{"email":"your-email@gmail.com","name":"Mike","message":"Hi, I want to enquire about ....","products":["Product A","Product B"]}' \
https://rusty-forms.com/v1/digest/821f4a10-127c-46c6-bc80-8790d219575a -v
...
> Content-Type: application/json
>
< HTTP/1.1 201 Created
Python Library v0.1.0+
To support more login methods, I have made minor changes to how you initiate the python library.
Old approach
1
2
3
4
5
6
7
8
from rusty-forms import RustyAPI, RustyAPIConfig
config = RustyAPIConfig()
config.generate_keys()
config.save()
api = RustyAPI(config)
api.login()
New approach
1
2
3
4
5
6
7
8
from rusty-forms import RustyAPI, NostrAuthApiConfig
auth = NostrAuthApiConfig()
auth.generate_keys()
auth.save()
api = RustyAPI(auth) # ... base_url, timeout
api.login()
As of v0.1.0
This post is licensed under
CC BY 4.0
by the author.