Search code examples
python-3.xrobots.txtmasonite

How to serve robots.txt from Masonite


I want to serve the files like robots.txt, humans.txt and manifest.json.

I saw the docs, I didn't find a solution, I have found view.render only serve HTML not text or JSON or any other file.


Solution

  • Add folder path and alias in config/storage.py

    # config/storage.py
    
    STATICFILES = {
        'storage/static': 'static/',
        'storage/compiled': 'static/',
        'storage/uploads': 'static/',
        'storage/root': '/' # add this line
    }
    

    Create root folder inside storage and put the robots.txt in root folder.

    visit localhost:8000/robots.txt