-
Notifications
You must be signed in to change notification settings - Fork 83
Clarify use and purpose of templates in this repo #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,14 @@ | |
| from flask import Flask, request | ||
| from function import handler | ||
| from waitress import serve | ||
| import os | ||
|
|
||
| app = Flask(__name__) | ||
|
|
||
| # distutils.util.strtobool() can throw an exception | ||
| def is_true(val): | ||
| return len(val) > 0 and val.lower() == "true" or val == "1" | ||
|
|
||
| @app.before_request | ||
| def fix_transfer_encoding(): | ||
| """ | ||
|
|
@@ -22,7 +27,14 @@ def fix_transfer_encoding(): | |
| @app.route("/", defaults={"path": ""}, methods=["POST", "GET"]) | ||
| @app.route("/<path:path>", methods=["POST", "GET"]) | ||
| def main_route(path): | ||
| ret = handler.handle(request.get_data()) | ||
| raw_body = os.getenv("RAW_BODY") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a semblance of consistency -> https://github.com/openfaas/templates/blob/master/template/node12/index.js#L11 |
||
|
|
||
| as_text = True | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To enable easier migration from the |
||
|
|
||
| if is_true(raw_body): | ||
| as_text = False | ||
|
|
||
| ret = handler.handle(request.get_data(as_text=as_text)) | ||
| return ret | ||
|
|
||
| if __name__ == '__main__': | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there is a typo, it is
waitressnotwitness