Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8542025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:57:52+00:00 2026-06-11T11:57:52+00:00

If you wanted to make a very simple file browser, let’s say /some/folder on

  • 0

If you wanted to make a very simple file browser, let’s say /some/folder on server, and let the flask app run and handle any requests for /here/ to be /some/folder/here and then dig deeper? Because flask has that @app.route(('/') so each request is mapped to a function, but here you would like one function, say browse to handle all requests, and block requests for /../../, for example.

Is flask not well suited for this? Should I look for something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:57:54+00:00Added an answer on June 11, 2026 at 11:57 am

    This is quite doable. See http://flask.pocoo.org/snippets/57/ for an example.

    @app.route('/', defaults={'path': ''})
    @app.route('/<path:path>')
    def catch_all(path):
        return 'You want path: %s' % path
    

    You should handle everything after the / as a path into your folder. You can then simply open that file name using open and write it as the Flask response.

    E.g.

     my_path = os.path.join(my_folder, path)
     with open(my_path) as the_file:
         # do stuff
    

    You might need to massage the path so that it is platform independent, using os.path.separator and os.path.join etc.

    Also, you will need determine the mimetype for the file you are returning and . This can be done using the module mimetypes.

    Also, see this link for the mechanics of returning a file directly, without having to read and return it. In python using Flask, how can I write out an object for download?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to make some simple file recovery software, where I want to try
I wanted to very quickly to make a simple drawing app for iOS, but
Very new to javascript and html-type stuff. I wanted to just make a quick
I wanted to make a JOptionPane.showOptionDialog with some JTextArea and JLabel . The problem
I wanted to make a simple Countdown-Application with C# to show as an example.
Lets say I wanted to make a post request to update the status of
I'm currently trying to read in an XML file, make some minor changes (alter
I am very new to Python programming (15 minutes) I wanted to make a
I wanted to make a Java based web crawler for an experiment. I heard
I wanted to make my top left hand corner of a table rounded in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.