-3

I have been trying to make a website using python (flask) as the backend with javascript on the client side. It genrealy works, but the problem is when i start it on my main PC i get the following error: "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.". When i start the same project on my laptop it works flawlessly.

At first i thought it might be because i was using two diffrent Python versions (3.11 and 3.9) but after trying both on both machines, it still worked on the laptop but not the PC.

Here is the python code running the server:

import json
import os
from Server.Accounts.accountManagement import loadAccount
from flask import Flask, send_from_directory

app = Flask(__name__)
app.debug = True
app._staic_folder = os.path.abspath("files/static/")



@app.route('/') 
def serve_files():
    return send_from_directory('files', "homepage.html")


@app.route("/profile")
def profile():
    data = loadAccount.getAccount("Ignitz")
    data = json.dumps(data, indent=4)
    return data



if __name__ == '__main__':
    app.run(host="localhost", port=3000, debug=True)
Ignitz
  • 15
  • 3
  • Does this answer your question? [Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain"](https://stackoverflow.com/questions/59908927/failed-to-load-module-script-the-server-responded-with-a-non-javascript-mime-ty) – arshovon May 27 '23 at 16:38
  • Not really, the problem isn't that its not working at all, its that its just not working on one machine. – Ignitz May 27 '23 at 17:12

1 Answers1

0

So, it works differently on Linux/OSX than on Windows. On Linux/OSX, it looks inside your FILES. On Windows, it looks through the registry. So, you have to go to the folder and change the type.

DevBev3
  • 3
  • 5
  • Thanks for anwsering, I don't have this in my code (neither on my pc or my laptop), maybe im not understanding it right, but im not using "http.server" or "socketserver". Is there a way to change content type with "flask" or "outside of code"? – Ignitz May 27 '23 at 18:24
  • Sure, I will see if I can do that. It could be that one of them has the setting by default. – DevBev3 May 27 '23 at 19:00