ERROR:tornado.general:Could not open static file - javascript

I'm writing a tornado web app and have a file named "static" with files such as main.js, require.js, elasticsearch.js, and d3.v3.js. The last three are just source code for the javascript libraries.
In my index.html file I have the lines
<script>src={{ static_url("scripts/require.js") }}></script>
<script>require([{{ static_url("scripts/main.js") }}], function () {})</script>
Now when I run the app, I get two errors:
ERROR:tornado.general:Could not open static file '...'
for each of my two files that I'm reading in. Has anyone ever had a similar issue or have any insights as to why this is happening?

Are the js files directly in the static directory or in a scripts subdirectory? Assuming you did something like static_path="static" when creating the application, the files need to live in static/scripts/*.js to match the paths you use in your static_url call.

Related

HTML include js files

I realize this question has been asked many times, however I don't manage to make it working
I have an html file (main.html) that is including two js files (etherjs.js and web3-min.js). These files are in the same directory.
But when requesting the page through localhost node server, the files are not included in the page
What I am doing wrong?
Error of the console (it is saying error loading the eleent which source is:):
I think the problem is with your server.
If you use express:
To serve static files such as images, CSS files, and JavaScript files,
use the express.static built-in middleware function in Express.
Make a folder callled public in the root.
Set it in your server: app.use(express.static('public'));
Put in the files you need eg.: some.js.
Now you can call it with <script src="/some.js"></script>
More information

Loading plugins in Webpack for a static website

I'm building a static website,
I have downloaded some template just get things started.
There are three main JS files in this template:
jquery.js
plugins.js
functions.js
They are loaded in the index.html file in that order.
I would like to use webpack for production.
I have created a new file: index.js and in that file, used require to load these files
require('jquery.js')
require('plugins.js')
require('functions.js')
This is not working because of probably scope issues, plugins.js for example doesn't know about jquery and so on.
I can move all the plugins from plugins.js to package.json and have it downloaded to node_modules and use it from there, but because it's a static website and just a FE to my app, I don't care much about updates to its packages (and another reason, there are a lot of plugins there...).
How can I make jquery.js and plugins.js symbols to be seen by functions.js?
Thanks

Angular JS links from directories above

I've just found this weird looking issue. I run my angular app from the local server and gave my index.html file links from directories one level above it and program was unable to find them. My relative path looked like this:
<script src="../scripts/angular.min.js"></script>
Also when I run my app not from a server, just like a regular HTML file paths were correct. Is this a angular rule that files from directories above cannot be linked to the app. Or just I did something wrong?

serving static content in code structure generated by yeoman for angular fullstack

I am following the code structure generated by yeoman for angular fullstack.
I want to include a script called core.js in file called app.html.
<script src="core.js"></script>
I do not see express.static anywhere in this for serving static files.
I tried using it but it did not help.
It can not locate it and gives 404.
How do I get around this ?
It had happened before as well but I could get around it by using express.static and serving files from location pointed by it.
It did not help this time though.
Update:
I have app.html in folder called Music. In same folder, I have a sub folder called js where I have placed my core.js file that is to be included in app.html. I tried to access it using absolute as well as relative path but did not help and still gives 404.
In angular, the scripts go in the relevant subfolder of /scripts. Either in /controllers, /services/, /directives, etc. You then reference them in your html as such:
<script src="scripts/controllers/core.js"></script>
As for express.static, express is a NodeJS wrapper for HTTP. So that will be the service you create that lives on some Node server remotely. express.static allows the Node server to deliver static content files from the file set at the remote server. It does not go in your angular application.

Error with smartGWT

With smart gwt 4 when I run the application I get the following error
Core SmartClient JavaScript libraries appear not to be loaded.
If inheriting the NoScript SmartGWT modules, verify that the HTML file includes tags to load the SmartClient module .js files from the appropriate location within the WAR.
By default these files are present under [GWT app name]/sc/modules/.
com.smartgwt.client.core.JsObject$SGWT_WARN: Core SmartClient JavaScript libraries appear not to be loaded.
If inheriting the NoScript SmartGWT modules, verify that the HTML file includes tags to load the SmartClient module .js files from the appropriate location within the WAR.
By default these files are present under [GWT app name]/sc/modules/.
I have set the following jar in my classpath
smartgwt.jar
smartgw-skin.jar
and add the inhert in my .gwt.xml file
And in my jps file i add the script
Thanks in advance
Make sure all of the paths are correct and the files are there in your WAR. It's also important to understand how the GWT directory structure works inside WAR files (the relative paths are not always what you think they should be).
Have you tried using GWT.getModuleBaseURL() or GWT.getHostPageBaseURL() for your paths?
Check these other posts for more info:
Path for images folder in GWT project
https://groups.google.com/forum/#!topic/google-web-toolkit/PxdjqjMIlVY

Categories

Resources