Skip to content

Commit

Permalink
Merge pull request #68 from 0b01001001/dev
Browse files Browse the repository at this point in the history
fix starlette static file bug
  • Loading branch information
kemingy authored Oct 23, 2020
2 parents 021d842 + 4e044ab commit baf1f8b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/starlette_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get(self, request):
Route('/ping', Ping),
Mount('/api', routes=[
Route('/predict/{luck:int}', predict, methods=['POST'])
])
]),
])
api.register(app)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name='spectree',
version='0.3.8',
version='0.3.9',
author='Keming Yang',
author_email='kemingy94@gmail.com',
description=('generate OpenAPI document and validate request&response '
Expand Down
3 changes: 3 additions & 0 deletions spectree/plugins/starlette_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def find_routes(self):
routes = []

def parse_route(app, prefix=''):
# :class:`starlette.staticfiles.StaticFiles` doesn't have routes
if not app.routes:
return
for route in app.routes:
if route.path.startswith(f'/{self.config.PATH}'):
continue
Expand Down
4 changes: 3 additions & 1 deletion tests/test_plugin_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from starlette.routing import Mount, Route
from starlette.staticfiles import StaticFiles
from starlette.testclient import TestClient

from spectree import SpecTree, Response
Expand Down Expand Up @@ -60,7 +61,8 @@ async def user_score(request):
Mount('/user', routes=[
Route('/{name}', user_score, methods=['POST']),
])
])
]),
Mount('/static', app=StaticFiles(directory='docs'), name='static'),
])
api.register(app)

Expand Down

0 comments on commit baf1f8b

Please sign in to comment.