Skip to content

Add explicit "mimetype" to ensure CSS is handled correctly #630

@jzohrab

Description

@jzohrab

In issue #623 , @newexploder found and fixed a CSS issue where the files weren't getting loaded correctly. Weird that it happened on his/her machine only (so far), but the fix should probably be applied to the app code as it's very fast.

Borrowing from the notes in that issue:


Root Cause

The root cause was an incorrect MIME type being served for the CSS files.

  • Expected Content-Type: text/css
  • Actual Content-Type served: application/x-css

The Solution

The issue was resolved by adding two lines of code to the application factory file (lute/app_factory.py) to explicitly register the correct MIME type for CSS files within the Python environment.

  1. Add the mimetypes import to the top of the file:

    import mimetypes
  2. Add the following line after all the imports, before the create_app() function:

    mimetypes.add_type('text/css', '.css')

After adding this code and restarting the server, the CSS is now served with the correct text/css MIME type, and the application's layout renders perfectly.


This should be a very fast fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions