trpc-fastapi-python 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,373 @@
1
+ Metadata-Version: 2.5
2
+ Name: trpc-fastapi-python
3
+ Version: 1.0.0
4
+ Summary: The plugin for trpc about fastapi
5
+ Project-URL: Homepage, https://github.com/trpc-ecosystem/python-fastapi
6
+ Project-URL: Documentation, https://github.com/trpc-ecosystem/python-fastapi/blob/main/README.md
7
+ Author: tRPC Group
8
+ License: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: fastapi,microservice,trpc
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.8
20
+ Requires-Dist: annotated-types
21
+ Requires-Dist: fastapi
22
+ Requires-Dist: trpc-python; sys_platform != 'win32'
23
+ Requires-Dist: uvicorn
24
+ Provides-Extra: all
25
+ Requires-Dist: annotated-types; extra == 'all'
26
+ Requires-Dist: fastapi; extra == 'all'
27
+ Requires-Dist: jinja2; extra == 'all'
28
+ Requires-Dist: setuptools; extra == 'all'
29
+ Requires-Dist: websockets; extra == 'all'
30
+ Provides-Extra: dev
31
+ Requires-Dist: annotated-types; extra == 'dev'
32
+ Requires-Dist: black; extra == 'dev'
33
+ Requires-Dist: fastapi; extra == 'dev'
34
+ Requires-Dist: flake8; extra == 'dev'
35
+ Requires-Dist: httpx; extra == 'dev'
36
+ Requires-Dist: pytest; extra == 'dev'
37
+ Requires-Dist: pytest-asyncio; extra == 'dev'
38
+ Requires-Dist: setuptools; extra == 'dev'
39
+ Requires-Dist: uvicorn; extra == 'dev'
40
+ Requires-Dist: websockets; extra == 'dev'
41
+ Requires-Dist: yapf; extra == 'dev'
42
+ Provides-Extra: static
43
+ Requires-Dist: jinja2; extra == 'static'
44
+ Description-Content-Type: text/markdown
45
+
46
+ [中文](README.zh_CN.md) | English
47
+
48
+ # tRPC-FastAPI
49
+
50
+ tRPC-FastAPI is a FastAPI integration plugin for the tRPC-Python framework (`trpc_sdk`). It provides HTTP serving out of the box, so you can develop, debug, deploy, and call HTTP APIs quickly. FastAPI is used as the server, so this plugin supports the server side only. Any HTTP client can call it.
51
+
52
+ ## Features
53
+
54
+ - **FastAPI integration**:
55
+ - **Drop-in fit**: Integrates with the tRPC-Python framework and keeps every tRPC feature;
56
+ - **HTTP routing**: Supports every HTTP method (GET, POST, PUT, DELETE, HEAD, OPTIONS, and others);
57
+ - **Generated docs**: Generates OpenAPI/Swagger docs, including interactive API testing;
58
+ - **Type safety**: Full type-annotation support for a better development experience;
59
+ - **Development tools**:
60
+ - **Static files**: Serves static assets such as HTML, CSS, JS, and images;
61
+ - **Templates**: Integrates the Jinja2 template engine for dynamic page rendering;
62
+ - **Version info**: Reads and displays the FastAPI and plugin versions;
63
+ - **Deployment**:
64
+ - **Containers**: Supports Docker;
65
+ - **Cloud native**: Supports Kubernetes and other cloud-native environments;
66
+
67
+ ## Installation
68
+
69
+ ### Requirements
70
+
71
+ - Python 3.8+
72
+ - Linux / macOS (tRPC-Python does not support Windows)
73
+ - tRPC-Python-SDK
74
+
75
+ ### Install
76
+
77
+ tRPC-Python is currently pinned as a git dependency to the commit referenced above, and `pip` installs it together with the plugin:
78
+
79
+ ```bash
80
+ pip install -e .
81
+ # To install the extra that includes static templates:
82
+ # pip install -e ".[static]"
83
+ ```
84
+
85
+ ## Quick start
86
+
87
+ ### Basic usage
88
+
89
+ This assumes you already have a generated tRPC project. For the full walkthrough and the one-command run, see [examples/README.md](./examples/README.md). The main files are:
90
+
91
+ ```txt
92
+ examples/
93
+ ├── normal_http/
94
+ ├── http_sse_service.py
95
+ ├── http_websocket_service.py
96
+ ├── trpc_main.py
97
+ ├── run_examples.sh
98
+ ├── trpc_python.yaml # one process, one uvicorn
99
+ ├── trpc_python_merge_threads.yaml # one process, multiple handler threads
100
+ ├── trpc_python_separate_thread.yaml # one process, I/O and handlers split
101
+ └── trpc_python_separate.yaml # multi-process separate
102
+ ```
103
+
104
+ #### 1. Register HTTP routes
105
+
106
+ You can register routes in a separate file. The example below is [http_service.py](./examples/normal_http/_http_service.py):
107
+
108
+ ```python
109
+
110
+ from trpc_fastapi import fastapi_route
111
+
112
+ @fastapi_route("/fastapi_http", ["GET", "HEAD"], route_params={'response_model': dict})
113
+ async def fastapi_http(request: Request) -> dict:
114
+ """Test fastapi_http http"""
115
+ logger.debug(f"=== normal_http, http_req header: {request.headers} ===")
116
+ ctx = get_trpc_ctx()
117
+ msg = ctx.get_client_message()
118
+ register_service_name = "trpc.trpc_python_group.helloworld.Greeter1"
119
+ msg_info = f"\n\n test_route, register service_name: {register_service_name}"
120
+ msg_info = f"{msg_info}, callee_service_name: {msg.callee_service_name}\n\n"
121
+ logger.debug(f"=== normal_http, msg_info: {msg_info} ===")
122
+ return {"message": "This fastapi_http for [GET, HEAD]"}
123
+ ```
124
+
125
+ #### 2. RPC-style HTTP service
126
+
127
+ Code generated by the stub tool includes protobuf objects. Point it at `http_fastapi` and it is reachable as-is. Calling through the stub looks like this. Full source: [test_service_rpc](./examples/client/test_service_rpc.py):
128
+
129
+ ```python
130
+ from trpc_sdk.abc import TrpcContext
131
+ from trpc_sdk.client import Options
132
+ from trpc_sdk.serialization import SerializationType
133
+
134
+ async def test_sync_Greeter_SayHello():
135
+ """Test Greeter of SayHello"""
136
+ proxy = rpc.GreeterClientProxyImpl()
137
+ req = pb.HelloRequest()
138
+ req.msg = "[sync] Hi SayHello"
139
+ options = (Options().set_target('ip://127.0.0.1:8000').set_protocol('http').set_serialization_type(
140
+ SerializationType.PB).set_network('tcp').set_short_conn(True))
141
+ ctx = TrpcContext()
142
+ try:
143
+ ret = await proxy.asyncSayHello(ctx, req, options)
144
+ print(f"SayHello ret is {ret}")
145
+ assert ret is not None
146
+ except Exception as exc: # pylint: disable=broad-exception-caught
147
+ print(f"error {exc}")
148
+ assert 0
149
+ ```
150
+
151
+ curl:
152
+
153
+ ```sh
154
+ curl -X POST http://127.0.0.1:8000/trpc.trpc_python_group.helloworld.Greeter/SayHello \
155
+ -H 'Content-Type: application/json' -d '{"msg":"data"}'
156
+ ```
157
+
158
+ Import the route-registration module in `trpc_main.py`. The import must happen before `create_server`:
159
+
160
+ ```python
161
+ # Importing registers the plugin, so this has to come first.
162
+ import trpc_fastapi as _
163
+ # Import the registered HTTP service.
164
+ import normal_http as _
165
+ ```
166
+
167
+ To serve another protocol name through FastAPI (for example the a2a plugin), call `register_protocol_to_fastapi` at import time. This also has to happen before `create_server`:
168
+
169
+ ```python
170
+ from trpc_fastapi import register_protocol_to_fastapi
171
+
172
+ register_protocol_to_fastapi("a2a")
173
+ ```
174
+
175
+ #### 3. Configuration
176
+
177
+ See [trpc_python.yaml](./examples/trpc_python.yaml). When `global.processmodel` is omitted, the server is a single process with one event loop, and uvicorn runs on one thread of the service process.
178
+
179
+ ```yaml
180
+ server:
181
+ service:
182
+ - name: trpc.trpc_python_group.helloworld.FastApiGreeter
183
+ ip: 0.0.0.0
184
+ port: 8000
185
+ network: tcp
186
+ protocol: http_fastapi
187
+ ```
188
+
189
+ #### Process models
190
+
191
+ | Config | `global.processmodel` | uvicorn |
192
+ |---|---|---|
193
+ | [trpc_python.yaml](./examples/trpc_python.yaml) | omitted | one for the whole service |
194
+ | [trpc_python_merge_threads.yaml](./examples/trpc_python_merge_threads.yaml) | `single_process`, `handle_num: 2` | one, started on serving thread 0 |
195
+ | [trpc_python_separate_thread.yaml](./examples/trpc_python_separate_thread.yaml) | `single_process`, `io_handle_type: separate` | one, started on serving thread 0 |
196
+ | [trpc_python_separate.yaml](./examples/trpc_python_separate.yaml) | `multi_process`, `io_handle_type: separate`, `handle_num: 2` | one per rpc task, listening on 8000 with `SO_REUSEPORT`. The I/O process listens only on the tRPC port |
197
+
198
+ Multi-process separate snippet:
199
+
200
+ ```yaml
201
+ global:
202
+ processmodel:
203
+ mode: multi_process
204
+ io_handle_type: separate
205
+ handle_num: 2
206
+ ```
207
+
208
+ #### 4. Start the server
209
+
210
+ In [trpc_main.py](./examples/trpc_main.py), import the module that registers routes, such as `http_service.py` above.
211
+
212
+ ```sh
213
+ cd examples
214
+ ./run_examples.sh
215
+ # or start it by hand
216
+ python3 trpc_main.py --conf trpc_python.yaml
217
+ python3 trpc_main.py --conf trpc_python_separate.yaml
218
+ ```
219
+
220
+ #### 5. Call the service
221
+
222
+ - In a browser: http://{IP}:{Port}/docs (`IP` and `Port` come from the config file. If the address is `0.0.0.0`, use the IP of your environment.)
223
+
224
+ - With curl:
225
+
226
+ ```sh
227
+ curl -X GET http://127.0.0.1:8000/details -v
228
+ ```
229
+
230
+ ### Advanced features
231
+
232
+ #### SSE
233
+
234
+ - Server code: [http_sse_service](./examples/http_sse_service.py)
235
+
236
+ ```python
237
+ import asyncio
238
+ from fastapi.responses import StreamingResponse
239
+
240
+ from trpc_fastapi import fastapi_route
241
+
242
+ async def event_generator():
243
+ """
244
+ Simulate async events and push one message every second.
245
+ """
246
+ counter = 0
247
+ while True:
248
+ counter += 1
249
+ # SSE format: data: <message>\n\n
250
+ yield f"data: 这是第 {counter} 条消息\n\n"
251
+ await asyncio.sleep(1)
252
+
253
+ @fastapi_route('/sse', ["GET"])
254
+ async def sse_endpoint():
255
+ """
256
+ SSE endpoint. Returns the event stream.
257
+ """
258
+ return StreamingResponse(event_generator(), media_type='text/event-stream')
259
+ ```
260
+
261
+ - Import it in [trpc_main.py](./examples/trpc_main.py):
262
+
263
+ ```python
264
+ import http_sse_service as _
265
+ ```
266
+
267
+ - Client check:
268
+
269
+ ```sh
270
+ curl -X GET http://127.0.0.1:8000/sse -v
271
+ ```
272
+
273
+ #### WebSocket
274
+
275
+ - Server code: [http_websocket_service](./examples/http_websocket_service.py)
276
+
277
+ ```python
278
+ from fastapi import WebSocket
279
+ from fastapi.responses import HTMLResponse
280
+
281
+ from trpc_sdk.log import logger
282
+ from trpc_fastapi import fastapi_route
283
+
284
+ @fastapi_route("/ws", method="WEBSOCKET")
285
+ async def websocket_endpoint(websocket: WebSocket):
286
+ await websocket.accept()
287
+ try:
288
+ while True:
289
+ data = await websocket.receive_text()
290
+ await websocket.send_text(f"Message text was: {data}")
291
+ except Exception as e: # pylint: disable=broad-except
292
+ logger.error(f"websocket error: {e}")
293
+ ```
294
+
295
+ - Import it in [trpc_main.py](./examples/trpc_main.py):
296
+
297
+ ```python
298
+ import http_websocket_service as _
299
+ ```
300
+
301
+ - Client check:
302
+
303
+ ```sh
304
+ python3 examples/client/test_websocket_client.py
305
+ ```
306
+
307
+ #### Static files
308
+
309
+ See [static_http_service](./examples/normal_http/_static_http_service.py).
310
+
311
+ - Install
312
+
313
+ Static pages may need template rendering. This install is the one to use:
314
+
315
+ ```sh
316
+ pip install -e ".[static]"
317
+ ```
318
+
319
+ - Register the static directory
320
+
321
+ ```python
322
+ from trpc_fastapi import fastapi_register_static
323
+ # Directory of static files.
324
+ static_dir = Path(__file__).parent / "static"
325
+ # Files used by template rendering.
326
+ templates_dir = Path(__file__).parent / "templates"
327
+
328
+ fastapi_register_static("/static", static_dir)
329
+ ```
330
+
331
+ - Register the static route
332
+
333
+ ```python
334
+ from trpc_fastapi import fastapi_register_get, trpc_fastapi_version, get_fastapi_app
335
+
336
+ @fastapi_register_get("/", route_params={'response_class': HTMLResponse})
337
+ async def static_page(request: Request):
338
+ """Root path. Returns an HTML page."""
339
+ return templates.TemplateResponse(
340
+ request,
341
+ "static_page.html", {
342
+ "trpc_fastapi_version": trpc_fastapi_version,
343
+ "fastapi_version": fastapi_version,
344
+ "endpoints": get_all_endpoints()
345
+ })
346
+ ```
347
+
348
+ Call `get_fastapi_app()` inside an `async def` route. FastAPI runs synchronous routes in a thread pool, where the app bound to the current uvicorn thread is not available.
349
+
350
+ - In a browser: http://{IP}:{Port}/ (`IP` and `Port` come from the config file. If the address is `0.0.0.0`, use the IP of your environment.)
351
+
352
+ ### Development setup
353
+
354
+ ```bash
355
+ # After cloning, enter the project directory and install dev dependencies.
356
+ pip install -e ".[all]"
357
+
358
+ # Run tests
359
+ pytest tests
360
+
361
+ # Format the code
362
+ ./format.sh
363
+ ```
364
+
365
+ ### Commit conventions
366
+
367
+ - `feat:` for a new feature
368
+ - `fix:` for a bug fix
369
+ - `docs:` for a documentation update
370
+
371
+ ## License
372
+
373
+ This project is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file.
@@ -0,0 +1,4 @@
1
+ trpc_fastapi_python-1.0.0.dist-info/METADATA,sha256=K1RgjCaRDj2r8xuTr1HurE14xuUL7qBw5avB6AfEOuc,12033
2
+ trpc_fastapi_python-1.0.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
3
+ trpc_fastapi_python-1.0.0.dist-info/licenses/LICENSE,sha256=dhB8P1NUrgbnyDHwVNZ8yEY8jtXD45Ywxg9APQ8kbTk,11624
4
+ trpc_fastapi_python-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,210 @@
1
+ Tencent is pleased to support the open source community by making tRPC-FastAPI-Python available.
2
+
3
+ Copyright (C) 2026 Tencent. All rights reserved.
4
+
5
+ tRPC-FastAPI-Python is licensed under the Apache-2.0.
6
+
7
+
8
+ Terms of the Apache-2.0:
9
+ --------------------------------------------------------------------
10
+ Apache License
11
+ Version 2.0, January 2004
12
+ http://www.apache.org/licenses/
13
+
14
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
15
+
16
+ 1. Definitions.
17
+
18
+ "License" shall mean the terms and conditions for use, reproduction,
19
+ and distribution as defined by Sections 1 through 9 of this document.
20
+
21
+ "Licensor" shall mean the copyright owner or entity authorized by
22
+ the copyright owner that is granting the License.
23
+
24
+ "Legal Entity" shall mean the union of the acting entity and all
25
+ other entities that control, are controlled by, or are under common
26
+ control with that entity. For the purposes of this definition,
27
+ "control" means (i) the power, direct or indirect, to cause the
28
+ direction or management of such entity, whether by contract or
29
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
30
+ outstanding shares, or (iii) beneficial ownership of such entity.
31
+
32
+ "You" (or "Your") shall mean an individual or Legal Entity
33
+ exercising permissions granted by this License.
34
+
35
+ "Source" form shall mean the preferred form for making modifications,
36
+ including but not limited to software source code, documentation
37
+ source, and configuration files.
38
+
39
+ "Object" form shall mean any form resulting from mechanical
40
+ transformation or translation of a Source form, including but
41
+ not limited to compiled object code, generated documentation,
42
+ and conversions to other media types.
43
+
44
+ "Work" shall mean the work of authorship, whether in Source or
45
+ Object form, made available under the License, as indicated by a
46
+ copyright notice that is included in or attached to the work
47
+ (an example is provided in the Appendix below).
48
+
49
+ "Derivative Works" shall mean any work, whether in Source or Object
50
+ form, that is based on (or derived from) the Work and for which the
51
+ editorial revisions, annotations, elaborations, or other modifications
52
+ represent, as a whole, an original work of authorship. For the purposes
53
+ of this License, Derivative Works shall not include works that remain
54
+ separable from, or merely link (or bind by name) to the interfaces of,
55
+ the Work and Derivative Works thereof.
56
+
57
+ "Contribution" shall mean any work of authorship, including
58
+ the original version of the Work and any modifications or additions
59
+ to that Work or Derivative Works thereof, that is intentionally
60
+ submitted to Licensor for inclusion in the Work by the copyright owner
61
+ or by an individual or Legal Entity authorized to submit on behalf of
62
+ the copyright owner. For the purposes of this definition, "submitted"
63
+ means any form of electronic, verbal, or written communication sent
64
+ to the Licensor or its representatives, including but not limited to
65
+ communication on electronic mailing lists, source code control systems,
66
+ and issue tracking systems that are managed by, or on behalf of, the
67
+ Licensor for the purpose of discussing and improving the Work, but
68
+ excluding communication that is conspicuously marked or otherwise
69
+ designated in writing by the copyright owner as "Not a Contribution."
70
+
71
+ "Contributor" shall mean Licensor and any individual or Legal Entity
72
+ on behalf of whom a Contribution has been received by Licensor and
73
+ subsequently incorporated within the Work.
74
+
75
+ 2. Grant of Copyright License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ copyright license to reproduce, prepare Derivative Works of,
79
+ publicly display, publicly perform, sublicense, and distribute the
80
+ Work and such Derivative Works in Source or Object form.
81
+
82
+ 3. Grant of Patent License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ (except as stated in this section) patent license to make, have made,
86
+ use, offer to sell, sell, import, and otherwise transfer the Work,
87
+ where such license applies only to those patent claims licensable
88
+ by such Contributor that are necessarily infringed by their
89
+ Contribution(s) alone or by combination of their Contribution(s)
90
+ with the Work to which such Contribution(s) was submitted. If You
91
+ institute patent litigation against any entity (including a
92
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
93
+ or a Contribution incorporated within the Work constitutes direct
94
+ or contributory patent infringement, then any patent licenses
95
+ granted to You under this License for that Work shall terminate
96
+ as of the date such litigation is filed.
97
+
98
+ 4. Redistribution. You may reproduce and distribute copies of the
99
+ Work or Derivative Works thereof in any medium, with or without
100
+ modifications, and in Source or Object form, provided that You
101
+ meet the following conditions:
102
+
103
+ (a) You must give any other recipients of the Work or
104
+ Derivative Works a copy of this License; and
105
+
106
+ (b) You must cause any modified files to carry prominent notices
107
+ stating that You changed the files; and
108
+
109
+ (c) You must retain, in the Source form of any Derivative Works
110
+ that You distribute, all copyright, patent, trademark, and
111
+ attribution notices from the Source form of the Work,
112
+ excluding those notices that do not pertain to any part of
113
+ the Derivative Works; and
114
+
115
+ (d) If the Work includes a "NOTICE" text file as part of its
116
+ distribution, then any Derivative Works that You distribute must
117
+ include a readable copy of the attribution notices contained
118
+ within such NOTICE file, excluding those notices that do not
119
+ pertain to any part of the Derivative Works, in at least one
120
+ of the following places: within a NOTICE text file distributed
121
+ as part of the Derivative Works; within the Source form or
122
+ documentation, if provided along with the Derivative Works; or,
123
+ within a display generated by the Derivative Works, if and
124
+ wherever such third-party notices normally appear. The contents
125
+ of the NOTICE file are for informational purposes only and
126
+ do not modify the License. You may add Your own attribution
127
+ notices within Derivative Works that You distribute, alongside
128
+ or as an addendum to the NOTICE text from the Work, provided
129
+ that such additional attribution notices cannot be construed
130
+ as modifying the License.
131
+
132
+ You may add Your own copyright statement to Your modifications and
133
+ may provide additional or different license terms and conditions
134
+ for use, reproduction, or distribution of Your modifications, or
135
+ for any such Derivative Works as a whole, provided Your use,
136
+ reproduction, and distribution of the Work otherwise complies with
137
+ the conditions stated in this License.
138
+
139
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
140
+ any Contribution intentionally submitted for inclusion in the Work
141
+ by You to the Licensor shall be under the terms and conditions of
142
+ this License, without any additional terms or conditions.
143
+ Notwithstanding the above, nothing herein shall supersede or modify
144
+ the terms of any separate license agreement you may have executed
145
+ with Licensor regarding such Contributions.
146
+
147
+ 6. Trademarks. This License does not grant permission to use the trade
148
+ names, trademarks, service marks, or product names of the Licensor,
149
+ except as required for reasonable and customary use in describing the
150
+ origin of the Work and reproducing the content of the NOTICE file.
151
+
152
+ 7. Disclaimer of Warranty. Unless required by applicable law or
153
+ agreed to in writing, Licensor provides the Work (and each
154
+ Contributor provides its Contributions) on an "AS IS" BASIS,
155
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
156
+ implied, including, without limitation, any warranties or conditions
157
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
158
+ PARTICULAR PURPOSE. You are solely responsible for determining the
159
+ appropriateness of using or redistributing the Work and assume any
160
+ risks associated with Your exercise of permissions under this License.
161
+
162
+ 8. Limitation of Liability. In no event and under no legal theory,
163
+ whether in tort (including negligence), contract, or otherwise,
164
+ unless required by applicable law (such as deliberate and grossly
165
+ negligent acts) or agreed to in writing, shall any Contributor be
166
+ liable to You for damages, including any direct, indirect, special,
167
+ incidental, or consequential damages of any character arising as a
168
+ result of this License or out of the use or inability to use the
169
+ Work (including but not limited to damages for loss of goodwill,
170
+ work stoppage, computer failure or malfunction, or any and all
171
+ other commercial damages or losses), even if such Contributor
172
+ has been advised of the possibility of such damages.
173
+
174
+ 9. Accepting Warranty or Additional Liability. While redistributing
175
+ the Work or Derivative Works thereof, You may choose to offer,
176
+ and charge a fee for, acceptance of support, warranty, indemnity,
177
+ or other liability obligations and/or rights consistent with this
178
+ License. However, in accepting such obligations, You may act only
179
+ on Your own behalf and on Your sole responsibility, not on behalf
180
+ of any other Contributor, and only if You agree to indemnify,
181
+ defend, and hold each Contributor harmless for any liability
182
+ incurred by, or claims asserted against, such Contributor by reason
183
+ of your accepting any such warranty or additional liability.
184
+
185
+ END OF TERMS AND CONDITIONS
186
+
187
+ APPENDIX: How to apply the Apache License to your work.
188
+
189
+ To apply the Apache License to your work, attach the following
190
+ boilerplate notice, with the fields enclosed by brackets "[]"
191
+ replaced with your own identifying information. (Don't include
192
+ the brackets!) The text should be enclosed in the appropriate
193
+ comment syntax for the file format. We also recommend that a
194
+ file or class name and description of purpose be included on the
195
+ same "printed page" as the copyright notice for easier
196
+ identification within third-party archives.
197
+
198
+ Copyright [yyyy] [name of copyright owner]
199
+
200
+ Licensed under the Apache License, Version 2.0 (the "License");
201
+ you may not use this file except in compliance with the License.
202
+ You may obtain a copy of the License at
203
+
204
+ http://www.apache.org/licenses/LICENSE-2.0
205
+
206
+ Unless required by applicable law or agreed to in writing, software
207
+ distributed under the License is distributed on an "AS IS" BASIS,
208
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
+ See the License for the specific language governing permissions and
210
+ limitations under the License.