Add raw body support to python3 templates#207
Conversation
|
Thanks for the PR. Just bear in mind to fill out the template i.e. How Has This Been Tested? |
|
|
||
| # distutils.util.strtobool() can throw an exception | ||
| def is_true(val): | ||
| return val and val.lower() == "true" or val == "1" |
There was a problem hiding this comment.
A complete sentence for the doc string would be better, it is clear to me because i recommended strtobool, but a future contributor won't have the context
if you want to use strtobool, you could also do this
def is_true(val):
try:
return distutils.util.strtobool(val)
except:
return falsebut either method is good to me 👍
| return val and val.lower() == "true" or val == "1" | ||
|
|
||
|
|
||
| def get_stdin(): |
There was a problem hiding this comment.
I would guess that get_stdin() will produce an invalid set of bytes since it is reading lines, I would imagine it should attempt to read an entire payload as bytes. There may not even be any newlines in the binary input - i.e. a JPEG image.
There was a problem hiding this comment.
We need to see a test that verifies the input received in the function is a perfect match for the bytes inputted.
There was a problem hiding this comment.
If you accept the data in from a HTTP request (curl --data-binary @input.jpg), then write it to the container in /tmp you can use kubectl cp -n openfaas-fn pod/name ./local-file.jpg to get the file back and compare for instance.
There was a problem hiding this comment.
I have updated this PR and tested with image data and it is working fine. Image file written in container is rendering correctly.
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
|
Need to cross reference with openfaas/python-flask-template#38 |
This has been handled within |
|
Sorry to hijack this PR, but I opened a similar, but more extensive issue (#205) in May. In it, I proposed opening a PR with my tried-and-tested solution, but since I got no response on the issue, I didn't at the time. I've now created it as #217. Imho, my solution is less hackish, as it parses standard headers and doesn't require environment variable definition. It also is more extensive in functionality. I'd be happy to propose similar changes to the flask templates (actually have those running privately too). |
Signed-off-by: Vivek Singh vivekkmr45@yahoo.in
Description
Motivation and Context
Which issue(s) this PR fixes
Fixes #
How Has This Been Tested?
This has been tested on my local with kind
Types of changes
Impact to existing users
Checklist:
git commit -s