【问题标题】:How to serve robots.txt from Masonite如何从 Masonite 提供 robots.txt
【发布时间】:2018-10-07 16:56:29
【问题描述】:

我想提供robots.txthumans.txtmanifest.json 等文件。

我查看了文档,但没有找到解决方案,我发现 view.render 仅提供 HTML 而非文本或 JSON 或任何其他文件。

【问题讨论】:

    标签: python-3.x robots.txt masonite


    【解决方案1】:

    config/storage.py中添加文件夹路径和别名

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

    storage 中创建root 文件夹并将robots.txt 放入root 文件夹中。

    访问localhost:8000/robots.txt

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 2018-10-18
      • 2019-05-23
      • 2012-12-12
      相关资源
      最近更新 更多