Skip to content

Use "backend" instead of "server" #726

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

Merged
merged 11 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from sanic import Sanic, response

from idom import component
from idom.backend.sanic import Options, configure, use_request
from idom.core.types import ComponentConstructor
from idom.server.sanic import Options, configure, use_request

from .examples import get_normalized_example_name, load_examples

Expand Down
5 changes: 5 additions & 0 deletions docs/source/about/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Changed:

- IDOM's client now uses Preact instead of React - :pull:`721`

- Renamed ``idom.server`` to ``idom.backend`` - :pull:`726`

Other references to "server implementations" have been renamed to "backend
implementations" throughout the documentation and code.

Removed:

- ``redirect_root`` server option - :pull:`721`
Expand Down
2 changes: 1 addition & 1 deletion docs/source/guides/escape-hatches/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Escape Hatches

javascript-components
distributing-javascript
writing-your-own-server
writing-your-own-backend
writing-your-own-client

.. note::
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _Writing Your Own Backend:

Writing Your Own Backend 🚧
===========================

.. note::

Under construction 🚧
8 changes: 0 additions & 8 deletions docs/source/guides/escape-hatches/writing-your-own-server.rst

This file was deleted.

4 changes: 2 additions & 2 deletions docs/source/guides/getting-started/_examples/run_fastapi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# :lines: 11-

from idom import run
from idom.server import fastapi as fastapi_server
from idom.backend import fastapi as fastapi_server


# the run() function is the entry point for examples
Expand All @@ -11,7 +11,7 @@
from fastapi import FastAPI

from idom import component, html
from idom.server.fastapi import configure
from idom.backend.fastapi import configure


@component
Expand Down
4 changes: 2 additions & 2 deletions docs/source/guides/getting-started/_examples/run_flask.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# :lines: 11-

from idom import run
from idom.server import flask as flask_server
from idom.backend import flask as flask_server


# the run() function is the entry point for examples
Expand All @@ -11,7 +11,7 @@
from flask import Flask

from idom import component, html
from idom.server.flask import configure
from idom.backend.flask import configure


@component
Expand Down
4 changes: 2 additions & 2 deletions docs/source/guides/getting-started/_examples/run_sanic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# :lines: 11-

from idom import run
from idom.server import sanic as sanic_server
from idom.backend import sanic as sanic_server


# the run() function is the entry point for examples
Expand All @@ -11,7 +11,7 @@
from sanic import Sanic

from idom import component, html
from idom.server.sanic import configure
from idom.backend.sanic import configure


@component
Expand Down
4 changes: 2 additions & 2 deletions docs/source/guides/getting-started/_examples/run_starlette.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# :lines: 11-

from idom import run
from idom.server import starlette as starlette_server
from idom.backend import starlette as starlette_server


# the run() function is the entry point for examples
Expand All @@ -11,7 +11,7 @@
from starlette.applications import Starlette

from idom import component, html
from idom.server.starlette import configure
from idom.backend.starlette import configure


@component
Expand Down
4 changes: 2 additions & 2 deletions docs/source/guides/getting-started/_examples/run_tornado.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# :lines: 11-

from idom import run
from idom.server import tornado as tornado_server
from idom.backend import tornado as tornado_server


# the run() function is the entry point for examples
Expand All @@ -12,7 +12,7 @@
import tornado.web

from idom import component, html
from idom.server.tornado import configure
from idom.backend.tornado import configure


@component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from sanic.response import file

from idom import component, html
from idom.server.sanic import Options, configure
from idom.backend.sanic import Options, configure


app = Sanic("MyApp")
Expand Down
6 changes: 3 additions & 3 deletions docs/source/guides/getting-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ Section 2: Running IDOM

Once you've :ref:`installed IDOM <Installing IDOM>`, you'll want to learn how to run an
application. Throughout most of the examples in this documentation, you'll see the
:func:`~idom.server.utils.run` function used. While it's convenient tool for development
it shouldn't be used in production settings - it's slow, and could leak secrets through
debug log messages.
:func:`~idom.backend.utils.run` function used. While it's convenient tool for
development it shouldn't be used in production settings - it's slow, and could leak
secrets through debug log messages.

.. idom:: _examples/hello_world

Expand Down
36 changes: 18 additions & 18 deletions docs/source/guides/getting-started/installing-idom.rst
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
Installing IDOM
===============

Installing IDOM with ``pip`` will generally require doing so alongside a supported
server implementation. This can be done by specifying an installation extra using square
brackets. For example, if we want to run IDOM using `Starlette
<https://www.starlette.io/>`__ we would run:
Installing IDOM with ``pip`` will typically require doing so alongside a built-in
backend implementation. This can be done by specifying an installation extra using
square brackets. For example, if we want to run IDOM using the `Starlette
<https://www.starlette.io/>`__ backend we would run:

.. code-block:: bash

pip install "idom[starlette]"

If you want to install a "pure" version of IDOM without a server implementation you can
do so without any installation extras. You might do this if you wanted to user a server
which is not officially supported or if you wanted to manually pin your dependencies:
If you want to install a "pure" version of IDOM without a backend implementation you can
do so without any installation extras. You might do this if you wanted to use a backend
which does not have built-in support or if you wanted to manually pin your dependencies:

.. code-block:: bash

pip install idom


Officially Supported Servers
----------------------------
Built-in Backends
-----------------

IDOM includes built-in support for a variety web server implementations. To install the
IDOM includes built-in support for a variety backend implementations. To install the
required dependencies for each you should substitute ``starlette`` from the ``pip
install`` command above with one of the options below:

Expand All @@ -39,15 +39,15 @@ If you need to, you can install more than one option by separating them with com
pip install "idom[fastapi,flask,sanic,starlette,tornado]"

Once this is complete you should be able to :ref:`run IDOM <Running IDOM>` with your
chosen server implementation.
chosen implementation.


Installing In Other Frameworks
------------------------------
Other Backends
--------------

While IDOM can run in a variety of contexts, sometimes web frameworks require extra work
in order to integrate with them. In these cases, the IDOM team distributes bindings for
various frameworks as separate Python packages. For documentation on how to install and
While IDOM can run in a variety of contexts, sometimes frameworks require extra work in
order to integrate with them. In these cases, the IDOM team distributes bindings for
those frameworks as separate Python packages. For documentation on how to install and
run IDOM in these supported frameworks, follow the links below:

.. raw:: html
Expand Down Expand Up @@ -96,8 +96,8 @@ run IDOM in these supported frameworks, follow the links below:
:transparent-text-color:`Plotly Dash`


Installing for Development
--------------------------
For Development
---------------

If you want to contribute to the development of IDOM or modify it, you'll want to
install a development version of IDOM. This involves cloning the repository where IDOM's
Expand Down
56 changes: 28 additions & 28 deletions docs/source/guides/getting-started/running-idom.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Running IDOM
============

The simplest way to run IDOM is with the :func:`~idom.server.utils.run` function. This
The simplest way to run IDOM is with the :func:`~idom.backend.utils.run` function. This
is the method you'll see used throughout this documentation. However, this executes your
application using a development server which is great for testing, but probably not what
if you're :ref:`deploying in production <Running IDOM in Production>`. Below are some
Expand All @@ -12,18 +12,18 @@ Running IDOM in Production
--------------------------

The first thing you'll need to do if you want to run IDOM in production is choose a
server implementation and follow its documentation on how to create and run an
application. This is the server :ref:`you probably chose <Officially Supported Servers>`
when installing IDOM. Then you'll need to configure that application with an IDOM view.
We should the basics how how to run each supported server below, but all implementations
will follow a pattern similar to the following:
backend implementation and follow its documentation on how to create and run an
application. This is the backend :ref:`you probably chose <Built-in Backends>` when
installing IDOM. Then you'll need to configure that application with an IDOM view. We
show the basics of how to set up, and then run, each supported backend below, but all
implementations will follow a pattern similar to the following:

.. code-block::

from my_chosen_server import Application
from my_chosen_backend import Application

from idom import component, html
from idom.server.my_chosen_server import configure
from idom.backend.my_chosen_backend import configure


@component
Expand All @@ -34,17 +34,17 @@ will follow a pattern similar to the following:
app = Application()
configure(app, HelloWorld)

You'll then run this ``app`` using a `ASGI <https://asgi.readthedocs.io/en/latest/>`__ or
`WSGI <https://wsgi.readthedocs.io/>`__ server from the command line.
You'll then run this ``app`` using an `ASGI <https://asgi.readthedocs.io/en/latest/>`__
or `WSGI <https://wsgi.readthedocs.io/>`__ server from the command line.


Running with `FastAPI <https://fastapi.tiangolo.com>`__
.......................................................

.. idom:: _examples/run_fastapi

Then assuming you put this in ``main.py``, you can run the ``app`` using `Uvicorn
<https://www.uvicorn.org/>`__:
Then assuming you put this in ``main.py``, you can run the ``app`` using the `Uvicorn
<https://www.uvicorn.org/>`__ ASGI server:

.. code-block:: bash

Expand All @@ -56,8 +56,8 @@ Running with `Flask <https://palletsprojects.com/p/flask/>`__

.. idom:: _examples/run_flask

Then assuming you put this in ``main.py``, you can run the ``app`` using `Gunicorn
<https://gunicorn.org/>`__:
Then assuming you put this in ``main.py``, you can run the ``app`` using the `Gunicorn
<https://gunicorn.org/>`__ WSGI server:

.. code-block:: bash

Expand All @@ -82,8 +82,8 @@ Running with `Starlette <https://www.starlette.io/>`__

.. idom:: _examples/run_starlette

Then assuming you put this in ``main.py``, you can run the application using `Uvicorn
<https://www.uvicorn.org/>`__:
Then assuming you put this in ``main.py``, you can run the application using the
`Uvicorn <https://www.uvicorn.org/>`__ ASGI server:

.. code-block:: bash

Expand Down Expand Up @@ -143,25 +143,25 @@ Errors will be displayed where the uppermost component is located in the view:
.. idom:: _examples/debug_error_example


Server Configuration Options
----------------------------
Backend Configuration Options
-----------------------------

IDOM's various server implementations come with ``Options`` that can be passed to their
IDOM's various backend implementations come with ``Options`` that can be passed to their
respective ``configure()`` functions in the following way:

.. code-block::

from idom.server.<implementation> import configure, Options
from idom.backend.<implementation> import configure, Options

configure(app, MyComponent, Options(...))

To learn more read about the options for your chosen server ``<implementation>``:
To learn more read about the options for your chosen backend ``<implementation>``:

- :class:`idom.server.fastapi.Options`
- :class:`idom.server.flask.Options`
- :class:`idom.server.sanic.Options`
- :class:`idom.server.starlette.Options`
- :class:`idom.server.tornado.Options`
- :class:`idom.backend.fastapi.Options`
- :class:`idom.backend.flask.Options`
- :class:`idom.backend.sanic.Options`
- :class:`idom.backend.starlette.Options`
- :class:`idom.backend.tornado.Options`


Embed in an Existing Webpage
Expand All @@ -187,8 +187,8 @@ embedding one the examples from this documentation into your own webpage:
.. note::

For more information on how to use the client see the :ref:`Javascript API`
reference. Or if you need to, your can :ref:`write your own server implementation
<writing your own server>`.
reference. Or if you need to, your can :ref:`write your own backend implementation
<writing your own backend>`.

As mentioned though, this is connecting to the server that is hosting this
documentation. If you want to connect to a view from your own server, you'll need to
Expand Down
7 changes: 6 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ of HTML element called an ``h1`` `section heading
<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements>`__.
Importantly though, a ``@component`` decorator has been applied to the ``App`` function
to turn it into a :ref:`component <Your First Components>`. Finally, we :ref:`run
<Running IDOM>` an application server by passing the ``App`` component to the ``run()``
<Running IDOM>` a development server by passing the ``App`` component to the ``run()``
function.

.. note::

See :ref:`Running IDOM in Production` to learn how to use a production-grade server
to run IDOM.


Learning IDOM
-------------
Expand Down
2 changes: 1 addition & 1 deletion scripts/live_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)

from docs.app import IDOM_MODEL_SERVER_URL_PREFIX, Example, make_app, reload_examples
from idom.server.sanic import Options, configure, serve_development_app
from idom.backend.sanic import Options, configure, serve_development_app
from idom.testing import clear_idom_web_modules_dir


Expand Down
Loading