The core application.
Functions
run_application (component, *[, ...]) |
Configure logging and start the given root component in the default asyncio event loop. |
Classes
Blueprint (name[, parent, prefix, ...]) |
A Blueprint class contains a Map of URL rules, which is checked and ran for every |
Context ([parent, default_timeout]) |
Contexts give request handlers and callbacks access to resources. |
HTTPRequestContext (parent, request) |
The context subclass passed to all requests within Kyoukai. |
Kyoukai (application_name, *[, server_name]) |
The Kyoukai type is the core of the Kyoukai framework, and the core of your web application based upon the Kyoukai framework. |
Request (environ[, populate_request, shallow]) |
Full featured request object implementing the following mixins: |
Response ([response, status, headers, ...]) |
Full featured response object implementing the following mixins: |
Exceptions
HTTPException ([description, response]) |
Baseclass for all HTTP exceptions. |
InternalServerError ([description, response]) |
500 Internal Server Error |
MethodNotAllowed ([valid_methods, description]) |
405 Method Not Allowed |
NotFound ([description, response]) |
404 Not Found |
RequestRedirect (new_url) |
Raise if the map requests a redirect. |
kyoukai.app.
Kyoukai
(application_name, *, server_name=None, **kwargs)[source]¶Bases: object
The Kyoukai type is the core of the Kyoukai framework, and the core of your web application based upon the Kyoukai framework. It acts as a central router and request processor that takes in requests from the protocols and returns responses.
The application name is currently unused, but it is good practice to set it correctly anyway in case it is used in future editions of Kyoukai.
You normally create an application instance inside your component file, like so:
from kyoukai.app import Kyoukai
... # setup code
kyk = Kyoukai("my_app")
kyk.register_blueprint(whatever)
... # other setup
class MyContainer(ContainerComponent):
async def start(self, ctx):
self.add_component('kyoukai', KyoukaiComponent, ip="127.0.0.1", port=4444,
app="app:app")
Of course, you can also embed Kyoukai inside another app, by awaiting Kyoukai.start()
.
Parameters: |
|
---|
request_class
¶The class of request to spawn every request.
This should be a subclass of werkzeug.wrappers.Request
.
You can override this by passing request_class
as a keyword argument to the app.
alias of Request
response_class
¶The class of response to wrap automatically.
This should be a subclass of werkzeug.wrappers.Response
.
You can override this by passing response_class
as a keyword argument to the app.
alias of Response
register_blueprint
(child)[source]¶Registers a child blueprint to this app’s root Blueprint.
This will set up the Blueprint tree, as well as setting up the routing table when finalized.
Parameters: | child (Blueprint ) – The child Blueprint to add. This must be an instance of Blueprint . |
---|
finalize
()[source]¶Finalizes the app and blueprints.
This will calculate the current werkzeug.routing.Map
which is required for
routing to work.
handle_httpexception
(self, ctx, exception, environ=None)[source]¶Handle a HTTP Exception.
Parameters: |
|
---|---|
Return type: | |
Returns: | A |
process_request
(self, request, parent_context)[source]¶Processes a Request and returns a Response object.
This is the main processing method of Kyoukai, and is meant to be used by one of the HTTP server backends, and not by client code.
Parameters: |
|
---|---|
Return type: | |
Returns: | A |
start
(self, ip='127.0.0.1', port=4444, *, component=None, base_context=None)[source]¶Runs the Kyoukai component asynchronously.
This will bypass Asphalt’s default runner, and allow you to run your app easily inside something else, for example.
Parameters: |
|
---|