Error "Cannot GET /site" while using browsersync - html

I am using the following command to run browsersync
browser-sync start --directory --files "*"
I have nodejs installed with permissions given to go past the firewall.
When I goto localhost:3000, I am able to see index.html.
When I click on index.html, I get an error message "Cannot Get /site".
How do I resolve this?
Below is index.html
<!DOCTYPE html>
<html>
<head>
<title>Hello Coursera</title>
</head>
<body>
<h1> Hello World. Another change</h1>
<h2>Pied piper is from Hamlin</h2>
<script id="__bs_script__">//<![CDATA[
document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.js?v=2.27.10'><\/script>".replace("HOST", location.hostname)); //]]></script>
</body>
</html>
Appreciate the help in advance.
I am trying to load a simple page via browsersync. I was expecting to load a page which says "Hello World"
Instead, I am getting an error "Cannot GET /site"

Related

Can't run or embed google Web App

I'm just learning google script and want to start by making a simple hello world. I have done google's tutorial and when I click "test this code" on the publish web app popup, the code runs and I get my basic hello world result. Great. But When I paste the provided URL into the browser or embed that same URL into google sites, I just get a blank page.
How do I run an web app? Am I missing something?
code.gs:
function doGet() {
var html= HtmlService
.createTemplateFromFile('Index');
html.name = 'David';
return html.evaluate();
}
index.html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<b>Hi <?=name?>!</b>
</body>
</html>
Coming from a basic PHP background, I'm used to just going to the URL of the .php file and bang, away it goes... I'm so confused.
https://stackoverflow.com/a/40843413/6288442
Google had just recently enabled this feature. It has been under a
'feature request' status for quite a long time. Link here
You can now explicitly define X-Frame-Options.
To allow embedding under another domain, the option should be
HtmlService.XFrameOptionsMode.ALLOWALL
Google documentation on the subject:
https://developers.google.com/apps-script/reference/html/html-output#setXFrameOptionsMode(XFrameOptionsMode)
Example:
function doGet() {
return HtmlService.createTemplateFromFile('form.html')
.evaluate() // evaluate MUST come before setting the Sandbox mode
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL); }
Hope this helps!
I think this should work
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<b>Hi <?!=name?></b>
</body>
</html>
https://developers.google.com/apps-script/guides/html/templates#force-printing_scriptlets
Name of file should also be exactly same
I think Index and index won't work

Can I run a batch file when I open my html document

I am trying to get a batch file to load in my head tag when I open my document
I have tried these and they don't seem to work:
<head onLoad="shutdown.bat">
<head onLoad="window.open('shutdown.bat')">
I've tried this as well putting it in to a function then calling it on load up
<head onLoad="shut">
<script>
function shut() {
}
</script>
</head>
I have made sure the batch file works by opening it as well
This is only possible to do when you are opening your HTML file through file:/// on your local computer. As soon as you host it on a server it will throw an error.
What you want to do though is this:
window.open("file:"///C:/Path/To/File/some_bat_file.bat"

Apps Script Sidebar Reference Error When Using Include

I created a Google Apps Script add-on to display a sidebar on click:
function displayPage_() {
getScriptProperties_()
var htmlTemplate = HtmlService.createTemplateFromFile('PAGE');
var html = htmlTemplate.evaluate()
.setTitle('Connector');
SpreadsheetApp.getUi().showSidebar(html);
}
This successfully loads the file PAGE.html as long as it is simple html. However, when I try to add include like this:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<?!= include("STYLESHEET"); ?>
</head>
<body>
</body>
</html>
It throws this error:
[17-02-09 08:55:50:239 MST] Execution failed: ReferenceError: "include" is not defined.
It doesn't matter what is in the include it always fails.
I have done this before and it worked. As far as I can tell, I have this set up just like the other project, but it doesn't work in this project. I assume that I forgot to enable something, but don't know how to tell what is missing because the transcript is vague.
What am I missing? Or, doing wrong?
I got crazy too...
Found it in an example provided in Google Script Reference, what I didn't know was that include() is a user-defined function. Paste this code and it will work:
function include(File) {
return HtmlService.createHtmlOutputFromFile(File).getContent();
};
Let me know if I understood properly.

Google drive website upload Failed Upload HTTP error (6)

I am trying to create a website to upload a file to Google Drive from my website, but I have had a lot of trouble.
I have used this code:
<!DOCTYPE html>
<html>
<head>
<title>Save to Drive Demo: Explicit Render</title>
<link rel="canonical" href="http://samrobbins.125mb.com/googledrive.html">
<script src="https://apis.google.com/js/platform.js">
{parsetags: 'explicit'}
</script>
</head>
<body>
Render the Save to Drive button
<div id="savetodrive-div"></div>
<script>
function renderSaveToDrive() {
gapi.savetodrive.render('savetodrive-div', {
src: 'http://samrobbins.125mb.com/knowledgebase.py',
filename: 'Cat.py',
sitename: 'The electronic cat database'
});
}
document.getElementById('render-link').addEventListener('click', renderSaveToDrive);
</script>
</body>
</html>
But when I load it, it says there is Failed Upload HTTP error (6)
Is there any way to stop this?
http error 6 is could not resolve host name. Your server may be down or the data-src server may be down. Try later.
You are sharing from a google drive. the default visibility of a google drive doc is private. You should change this to public.
Check the box next to a file/folder and click the Share button at the top of your file list

"Unknown error" in my Chrome extension

I am writing (or attempting to write) my first Chrome extension, and I cannot figure out this error I keep getting. My background code is
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
console.log('works?');
chrome.tabs.executeScript(null, {code:"document.body.style.fontSize = 20"});
console.log('print again');
</script>
</body>
When I try to run this extension I get the error:
Error during tabs.executeScript: Unknown error. extensions/extension process bindings.js:85
Does anyone have any idea what this could possibly be or how to fix it? I get no error when I do not include the line chrome.tabs.executeScript, and I get the error no matter what I write for the parameters of chrome.tabs.executeScript.
I also get the error when I include chrome.tabs.executeScript inside a function that is called whenever the browserAction is clicked
Any help would be much appreciated, thank you!
You are injecting code into selected tab right when background page loads for the first time, which happens on chrome://extensions page where you cannot inject anything.
Not sure why you are still getting error inside browser action listener, maybe you have extensions page still opened?