Skip to content

Commit

Permalink
Merge branch 'master' into 2182-http-date-dt-aware
Browse files Browse the repository at this point in the history
  • Loading branch information
vytas7 authored Jul 13, 2024
2 parents c4fdd45 + 09189a8 commit 107e2f0
Show file tree
Hide file tree
Showing 113 changed files with 310 additions and 317 deletions.
4 changes: 4 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ while remaining highly effective.

.. code:: python
import falcon
class QuoteResource:
def on_get(self, req, resp):
Expand All @@ -36,6 +38,8 @@ while remaining highly effective.
app = falcon.App()
app.add_route('/quote', QuoteResource())
For a fully working example, check out the :ref:`quickstart`.

Quick Links
-----------

Expand Down
10 changes: 6 additions & 4 deletions docs/user/tutorial-asgi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ We can now implement a basic async image store. Save the following code as
import io
import aiofiles
import falcon
import PIL.Image
import falcon
class Image:
def __init__(self, config, image_id, size):
Expand Down Expand Up @@ -266,6 +267,7 @@ of images. Place the code below in a file named ``images.py``:
.. code:: python
import aiofiles
import falcon
Expand Down Expand Up @@ -670,8 +672,6 @@ The new ``thumbnails`` end-point should now render thumbnails on the fly::
Again, we could also verify thumbnail URIs in the browser or image viewer that
supports HTTP input.



.. _asgi_tutorial_caching:

Caching Responses
Expand Down Expand Up @@ -979,9 +979,11 @@ your ASGI Falcon application:

.. code:: python
import falcon
import logging
import falcon
logging.basicConfig(level=logging.INFO)
class ErrorResource:
Expand Down
35 changes: 22 additions & 13 deletions docs/user/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,9 @@ Then, update the responder to use the new media type:

.. code:: python
import falcon
import msgpack
import falcon
class Resource:
Expand Down Expand Up @@ -467,11 +466,12 @@ Next, edit ``test_app.py`` to look like this:

.. code:: python
import falcon
from falcon import testing
import msgpack
import pytest
import falcon
from falcon import testing
from look.app import app
Expand Down Expand Up @@ -601,9 +601,10 @@ POSTs. Open ``images.py`` and add a POST responder to the
import uuid
import mimetypes
import falcon
import msgpack
import falcon
class Resource:
Expand Down Expand Up @@ -723,9 +724,10 @@ operation:
import os
import uuid
import falcon
import msgpack
import falcon
class Resource:
Expand Down Expand Up @@ -789,7 +791,8 @@ Hmm, it looks like we forgot to update ``app.py``. Let's do that now:
import falcon
from .images import ImageStore, Resource
from .images import ImageStore
from .images import Resource
app = application = falcon.App()
Expand All @@ -813,7 +816,8 @@ similar to the following:
import falcon
from .images import ImageStore, Resource
from .images import ImageStore
from .images import Resource
def create_app(image_store):
Expand Down Expand Up @@ -849,11 +853,12 @@ look similar to this:
from unittest.mock import call, MagicMock, mock_open
import falcon
from falcon import testing
import msgpack
import pytest
import falcon
from falcon import testing
import look.app
import look.images
Expand Down Expand Up @@ -1041,7 +1046,8 @@ the image storage directory with an environment variable:
import falcon
from .images import ImageStore, Resource
from .images import ImageStore
from .images import Resource
def create_app(image_store):
Expand Down Expand Up @@ -1123,9 +1129,10 @@ Go ahead and edit your ``images.py`` file to look something like this:
import uuid
import mimetypes
import falcon
import msgpack
import falcon
class Collection:
Expand Down Expand Up @@ -1234,7 +1241,9 @@ similar to the following:
import falcon
from .images import Collection, ImageStore, Item
from .images import Collection
from .images import ImageStore
from .images import Item
def create_app(image_store):
Expand Down
1 change: 0 additions & 1 deletion e2e-tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import falcon.testing


HERE = pathlib.Path(__file__).resolve().parent
INDEX = '/static/index.html'

Expand Down
4 changes: 3 additions & 1 deletion e2e-tests/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import falcon
import falcon.asgi

from .chat import Chat
from .hub import Events, Hub
from .hub import Events
from .hub import Hub
from .ping import Pong

HERE = pathlib.Path(__file__).resolve().parent
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/server/chat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re

from falcon.asgi import Request, WebSocket
from falcon.asgi import Request
from falcon.asgi import WebSocket

from .hub import Hub

Expand Down
5 changes: 4 additions & 1 deletion e2e-tests/server/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import typing
import uuid

from falcon.asgi import Request, Response, SSEvent, WebSocket
from falcon.asgi import Request
from falcon.asgi import Response
from falcon.asgi import SSEvent
from falcon.asgi import WebSocket


class Emitter:
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/server/ping.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from http import HTTPStatus

import falcon
from falcon.asgi import Request, Response
from falcon.asgi import Request
from falcon.asgi import Response


class Pong:
Expand Down
3 changes: 2 additions & 1 deletion examples/asgilook/asgilook/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from .cache import RedisCache
from .config import Config
from .images import Images, Thumbnails
from .images import Images
from .images import Thumbnails
from .store import Store


Expand Down
1 change: 0 additions & 1 deletion examples/asgilook/asgilook/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import msgpack
import redis.asyncio as redis


class RedisCache:
Expand Down
3 changes: 2 additions & 1 deletion examples/asgilook/asgilook/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
import pathlib
import redis.asyncio
import uuid

import redis.asyncio


class Config:
DEFAULT_CONFIG_PATH = '/tmp/asgilook'
Expand Down
1 change: 1 addition & 0 deletions examples/asgilook/asgilook/images.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import aiofiles

import falcon


Expand Down
3 changes: 2 additions & 1 deletion examples/asgilook/asgilook/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import io

import aiofiles
import falcon
import PIL.Image

import falcon


class Image:
def __init__(self, config, image_id, size):
Expand Down
5 changes: 3 additions & 2 deletions examples/asgilook/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import uuid

import fakeredis.aioredis
import falcon.asgi
import falcon.testing
import PIL.Image
import PIL.ImageDraw
import pytest

import falcon.asgi
import falcon.testing

from asgilook.app import create_app
from asgilook.config import Config

Expand Down
3 changes: 2 additions & 1 deletion examples/look/look/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import falcon

from .images import ImageStore, Resource
from .images import ImageStore
from .images import Resource


def create_app(image_store):
Expand Down
3 changes: 2 additions & 1 deletion examples/look/look/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import os
import uuid

import falcon
import msgpack

import falcon


class Resource:
def __init__(self, image_store):
Expand Down
1 change: 0 additions & 1 deletion examples/look/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import requests


LOOK_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))

gunicorn = None
Expand Down
9 changes: 6 additions & 3 deletions examples/look/tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import io
from unittest.mock import call
from unittest.mock import MagicMock
from unittest.mock import mock_open
from wsgiref.validate import InputWrapper

import falcon
from falcon import testing
from unittest.mock import call, MagicMock, mock_open
import msgpack
import pytest

import falcon
from falcon import testing

import look.app
import look.images

Expand Down
3 changes: 2 additions & 1 deletion examples/things_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import uuid
from wsgiref import simple_server

import falcon
import requests

import falcon


class StorageEngine:
def get_things(self, marker, limit):
Expand Down
3 changes: 2 additions & 1 deletion examples/things_advanced_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import logging
import uuid

import httpx

import falcon
import falcon.asgi
import httpx


class StorageEngine:
Expand Down
1 change: 0 additions & 1 deletion falcon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
from falcon.util import wrap_sync_to_async_unsafe
from falcon.version import __version__


# NOTE(kgriffs): Only to be used internally on the rare occasion that we
# need to log something that we can't communicate any other way.
_logger = _logging.getLogger('falcon')
Expand Down
Loading

0 comments on commit 107e2f0

Please sign in to comment.