Giter Site home page Giter Site logo

Comments (5)

LarryKlugerDS avatar LarryKlugerDS commented on July 27, 2024 7

The following is working for me:

files_index = AutoIndex(app, os.path.curdir + '/app/files', add_url_rules=False)
# Custom indexing
@app.route('/files')
@app.route('/files/<path:path>')
def autoindex(path='.'):
    return files_index.render_autoindex(path)

from flask-autoindex.

stephenbez avatar stephenbez commented on July 27, 2024

I think this is the way to do it:

idx = AutoIndex(app, '/home/blackfist/reports', add_url_rules=False)

@app.route('/reports')
@app.route('/reports/<path:path>')
def autoindex(path='.'):
    return idx.render_autoindex(path)

I figured this out by reading the code for the AutoIndex constructor

from flask-autoindex.

mrculler avatar mrculler commented on July 27, 2024

@stephenbez I'm seeing your solution get a bit closer to a working solution, but it still fails, I'm guessing because of flask-autoindex code changes since your comment here. Doing what you said makes a separately-routed autoindex work for an empty directory, but once there is a file or a subdirectory in there everything explodes.

BuildError: ('autoindex', {'path': './somefile'}, None)

I tried path.lstrip("./") and setting browse_root=False on the render_autoindex call but it nothing changed the output.

from flask-autoindex.

astanway avatar astanway commented on July 27, 2024

+1 for this feature - I also need to serve an auto index page on somewhere other than root.

from flask-autoindex.

general03 avatar general03 commented on July 27, 2024

You're right @LarryKlugerDS it's the solution !

from flask-autoindex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.