Open vsoch opened 9 years ago
This example is on python 2.7 not more supported
AssertionError: View function mapping is overwriting an existing endpoint function: silkicon
in python 3.8
Hi @WolfgangFahl ,
Could you put more information : code, how to reproduce ...
Thanks
This is how you can reproduce:
bc@anton-mbp ~/H/p/v/autoindex_multiple [1]> tree
.
├── app.py
├── first
│ └── 1.txt
└── second
└── 2.txt
2 directories, 3 files
bc@anton-mbp ~/H/p/v/autoindex_multiple> cat app.py
from flask import Flask
from flask_autoindex import AutoIndex
app = Flask(__name__)
first = AutoIndex(app, "first", add_url_rules=False)
second = AutoIndex(app, "second", add_url_rules=False)
@app.route("/first")
@app.route("/first/<path:path>")
def first_index(path="."):
return first.render_autoindex(path, endpoint=".first_index")
@app.route("/second")
@app.route("/second/<path:path>")
def second_index(path="."):
return second.render_autoindex(path, endpoint=".second_index")
if __name__ == "__main__":
app.run(debug=True)
bc@anton-mbp ~/H/p/v/autoindex_multiple> python app.py
Traceback (most recent call last):
File "app.py", line 7, in <module>
second = AutoIndex(app, "second", add_url_rules=False)
File "/Users/bc/.pyenv/versions/env/lib/python3.6/site-packages/flask_autoindex/__init__.py", line 242, in __init__
**silk_options)
File "/Users/bc/.pyenv/versions/env/lib/python3.6/site-packages/flask_autoindex/__init__.py", line 78, in __init__
self.silk = Silk(self.base, **silk_options)
File "/Users/bc/.pyenv/versions/env/lib/python3.6/site-packages/flask_silk/__init__.py", line 61, in __init__
self.silkicon = self.base.route(rule)(self.silkicon)
File "/Users/bc/.pyenv/versions/env/lib/python3.6/site-packages/flask/app.py", line 1315, in decorator
self.add_url_rule(rule, endpoint, f, **options)
File "/Users/bc/.pyenv/versions/env/lib/python3.6/site-packages/flask/app.py", line 98, in wrapper_func
return f(self, *args, **kwargs)
File "/Users/bc/.pyenv/versions/env/lib/python3.6/site-packages/flask/app.py", line 1284, in add_url_rule
"existing endpoint function: %s" % endpoint
AssertionError: View function mapping is overwriting an existing endpoint function: silkicon
thx for stepping in
It's FlaskSilk
issue because you can't have several app on the same path.
A rework is needed, detach this library
got same error today while trying to use multiple indexes in specific directoriers...any chance to get this fixed?
Using cacerts from /opt/freeware/lib/python3.7/site-packages/certifi/cacert.pem
Traceback (most recent call last):
File "/home/tremch/flask/authlib_keycloak_client_test/app.py", line 32, in <module>
daba_index = AutoIndex(app, '/srv/www/nmonchart/nmon4daba', add_url_rules=False)
File "/opt/freeware/lib/python3.7/site-packages/flask_autoindex/__init__.py", line 242, in __init__
**silk_options)
File "/opt/freeware/lib/python3.7/site-packages/flask_autoindex/__init__.py", line 78, in __init__
self.silk = Silk(self.base, **silk_options)
File "/opt/freeware/lib/python3.7/site-packages/flask_silk/__init__.py", line 61, in __init__
self.silkicon = self.base.route(rule)(self.silkicon)
File "/opt/freeware/lib/python3.7/site-packages/flask/scaffold.py", line 449, in decorator
self.add_url_rule(rule, endpoint, f, **options)
File "/opt/freeware/lib/python3.7/site-packages/flask/scaffold.py", line 50, in wrapper_func
return f(self, *args, **kwargs)
File "/opt/freeware/lib/python3.7/site-packages/flask/app.py", line 1362, in add_url_rule
"View function mapping is overwriting an existing"
AssertionError: View function mapping is overwriting an existing endpoint function: silkicon
Hi,
I want to define a custom route for the root (@root("/")) and then auto index only a specific set of directories from there. However, when I define multiple autoindex, it tells me that I am overwriting existing end point functions. For example:
I get the same error when I move the *_index inside the route functions.
Error:
Is there a better way to do this? The above functionality works only given that I define the AutoIndex once (eg, for one subdirectory). However I need to do it for several. Thanks for your help!