Skip to content
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

Route already registered: /swagger/<file_uri:/?.+> [GET,HEAD] #225

Closed
chongtwo opened this issue Apr 13, 2021 · 3 comments
Closed

Route already registered: /swagger/<file_uri:/?.+> [GET,HEAD] #225

chongtwo opened this issue Apr 13, 2021 · 3 comments

Comments

@chongtwo
Copy link

sanic 20.12.2
sanci-openapi 0.6.2
centos 7.4

When I run my project through pycharm all work fine, but when I package my project through pyinstaller and try to run the exe it cracks with the message that

File "sanic/app.py", line 718, in blueprint   
File "sanic/blueprints.py", line 151, in register   
File "sanic/app.py", line 696, in static   
File "sanic/static.py", line 175, in register   
File "sanic/app.py", line 217, in response  
File "sanic/router.py", line 158, in add   
File "sanic/router.py", line 317, in _add   
File "sanic/router.py", line 268, in merge_route
sanic.router.RouteExists: Route already registered: /swagger/<file_uri:/?.+> [GET,HEAD]

I have seen #216 but it doesn't seem to help.

@chongtwo chongtwo changed the title Traceback (most recent call last): File "app_service.py", line 21, in <module> File "sanic/app.py", line 718, in blueprint File "sanic/blueprints.py", line 151, in register File "sanic/app.py", line 696, in static File "sanic/static.py", line 175, in register File "sanic/app.py", line 217, in response File "sanic/router.py", line 158, in add File "sanic/router.py", line 317, in _add File "sanic/router.py", line 268, in merge_route sanic.router.RouteExists: Route already registered: /swagger/<file_uri:/?.+> [GET,HEAD] Route already registered: /swagger/<file_uri:/?.+> [GET,HEAD] Apr 13, 2021
@artcg
Copy link
Contributor

artcg commented Apr 13, 2021

Thanks for the report, i don't know about this one but one thing I can see which might help you is that your sanic version is outdated, could try version 20.12.3 which is the latest from the 2012 release,

would also recommend to try with sanic 18.12 and sanic 21.3 and see if either of those work

if not i could help you debug it if you share a small code sample which can recreate it

@artcg
Copy link
Contributor

artcg commented Apr 13, 2021

Will close this but please do re-open if that doesn't solve your problem

@artcg artcg closed this as completed Apr 13, 2021
@chongtwo
Copy link
Author

I've tried your suggestion but it didn't work.
The code is as below:

# sanic-openapi-test.py
from sanic import Sanic
from sanic.response import json
from sanic_openapi import swagger_blueprint

app = Sanic(name="sanic_openapi_test")
app.blueprint(swagger_blueprint)


@app.route("/")
async def test(request):
    return json({"hello": "world"})


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)

And I packaged the code by PyInstaller (pip install pyinstaller)

 pyinstaller sanic-openapi-test.py

Went into the dist directory that is made by the command above and ran the sanic_openapi_test.exe. The error appeared:

Traceback (most recent call last):
  File "sanic_openapi_test.py", line 6, in <module>
  File "sanic\app.py", line 421, in blueprint
  File "sanic\blueprints.py", line 234, in register
  File "sanic\app.py", line 345, in _apply_static
  File "sanic\mixins\routes.py", line 803, in _register_static
  File "sanic\mixins\routes.py", line 155, in decorator
  File "sanic\app.py", line 335, in _apply_route
  File "sanic\router.py", line 128, in add
  File "sanic_routing\router.py", line 170, in add
  File "sanic_routing\route.py", line 115, in add_handler
sanic_routing.exceptions.RouteExists: Route already registered: swagger/<__file_uri__> [GET]
[6444] Failed to execute script sanic_openapi_test

Hope you can help me solve this problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants