Unable to externally load script via src=""
See original GitHub issueFor some reason, I get this
brython.js:5183 Access to XMLHttpRequest at '../basichow/test.py?1572494543087' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
This occurs when I added the src="test.py"
to the
<script type="text/python"></script>
Using Chrome and Brython.js version 8.
The files are here.
basichow.zip
Any help be appreciated, thanks.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
javascript - External file script is not loading - Stack Overflow
Check your relative path to the utility.js file and make sure to load juery.js library before load utility.js file. and finally try this,...
Read more >How to Load External JavaScript Files From the Browser ...
This article will explain how you can load an external JavaScript file directly from the browser's console window as part of your prototyping ......
Read more >How to tell if a <script> tag failed to load? - GeeksforGeeks
The problem is to identify whether the passed script loaded successfully or not using JavaScript. There are two methods which are discussed ...
Read more >4. Loading Scripts Without Blocking - Even Faster Web Sites ...
The SRC attribute specifies the URL of the external file that needs to be loaded. The browser reads the script file from the...
Read more >Using External JavaScript Libraries | Lightning Aura ...
The framework's content security policy mandates that external JavaScript libraries must be uploaded to Salesforce static resources.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is already possible with Brython packages. If you run
python -m brython --make_package test
in the application directory, it generates the Javascript programtest.brython.js
that you can load withand then execute the code in main.py by
In this case there is no Ajax call, so the page will work with the
file
protocol. You can transfer the application files to a mobile phone and open the page, it will work 😃You have probably modified
test.py
with something likeThe Python function
open()
is also implemented in Brython with an Ajax call (browsers don’t have access to the computer file system). The call is blocking (ie not asynchronous) because the Python function is also blocking; this causes the deprecation message, but you can ignore it (cf. the Brython FAQ for more information). And the call fails anyway because the protocol isfile
.For the moment there is no real solution to this problem (you could put the file content inside a string in a Python script and import it, but that’s ugly…). I will try to find something better, I will keep you informed.