diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8fe672c..79ee295 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it diff --git a/liveandletdie/__init__.py b/liveandletdie/__init__.py index cde2466..2579cf7 100644 --- a/liveandletdie/__init__.py +++ b/liveandletdie/__init__.py @@ -568,8 +568,13 @@ def __init__(self, *args, **kwargs): def create_command(self): return [ self.executable, - '{}:app'.format(self.path), - '--host {}'.format(self.host), - '--port {}'.format(self.port), + '--app-dir', + os.path.dirname(self.path), + '--host', + self.host, + '--port', + str(self.port), + 'main:app', '--reload', ] + diff --git a/sample_apps/django/example/example/urls.py b/sample_apps/django/example/example/urls.py index 6535caa..d5c69c4 100644 --- a/sample_apps/django/example/example/urls.py +++ b/sample_apps/django/example/example/urls.py @@ -1,8 +1,6 @@ -from django.conf.urls import url - +from django.urls import include, re_path from example.views import home - urlpatterns = [ - url(r'^$', home, name='home'), + re_path(r'^$', home, name='home'), ] diff --git a/sample_apps/fastapi/main.py b/sample_apps/fastapi/main.py new file mode 100644 index 0000000..90118fa --- /dev/null +++ b/sample_apps/fastapi/main.py @@ -0,0 +1,13 @@ +# encoding: utf-8 +from fastapi import FastAPI, Request + +app = FastAPI() + + +@app.get('/') +def home(request: Request): + content = 'Home FastAPI' + if request.url.scheme == 'https': + content += ' SSL' + + return content diff --git a/setup.py b/setup.py index a831c45..2a6f078 100644 --- a/setup.py +++ b/setup.py @@ -29,14 +29,15 @@ 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Programming Language :: JavaScript', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: ' 'CGI Tools/Libraries', - 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Software Development :: Libraries', 'Topic :: Software Development :: Libraries :: Python Modules', ] diff --git a/test_examples/pytest_example/tests.py b/test_examples/pytest_example/tests.py index d2647c4..28010d7 100644 --- a/test_examples/pytest_example/tests.py +++ b/test_examples/pytest_example/tests.py @@ -39,6 +39,10 @@ def abspath(pth): abspath('sample_apps/django/example'), port=PORT ), + 'FastAPI': liveandletdie.FastAPIServer( + abspath('sample_apps/fastapi/main.py'), + port=PORT + ), } diff --git a/test_examples/unittest_example/tests.py b/test_examples/unittest_example/tests.py index 87dca41..a09b55c 100644 --- a/test_examples/unittest_example/tests.py +++ b/test_examples/unittest_example/tests.py @@ -83,6 +83,14 @@ class TestGAE(unittest.TestCase): app = liveandletdie.GAE(environ['VIRTUAL_ENV'] + '/bin/dev_appserver', abspath('sample_apps/gae'), port=PORT) +@test_decorator +class TestFastAPI(unittest.TestCase): + EXPECTED_TEXT = 'Home FastAPI' + app = liveandletdie.FastAPIServer( + abspath('sample_apps/fastapi/main.py'), + port=PORT + ) + if __name__ == '__main__': unittest.main() diff --git a/tox.ini b/tox.ini index 7765544..4a9dad8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,10 @@ [tox] -envlist=py36 +envlist=py311 [testenv] deps= django + fastapi flask lettuce pyramid @@ -11,6 +12,7 @@ deps= pyopenssl requests werkzeug + uvicorn setenv = PYTHONPATH={toxinidir} PYTHONWARNINGS=ignore