How do I send an image link through a golang created HTML page - html

I'm new to go and web apps and trying do write an app that reads menu items from a database and send the item's description and the link of a picture related to it through an HTML page for a browser. The app will run on a local network so the image will be in a place like "c:\images\01.png". As of now the page source created is something like
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p> Bolinho de Aipim<img src="01.png" alt="Ícone do Menu" width="42" height="42"></p>
<p> Bolinho de Bacalhau<img src="01.png" alt="Ícone do Menu" width="42" height="42"></p>
</body>
where 01.png is the picture file located on the same folder as the go serever app on the LAN server. Of course it will show the same file, but this is a test. In the real app there will be image folders and each item will have its corresponding image, of course.
Well, the page is created ,sent and shown correctly but the image is not shown. I believe this is an HTML problem, at which I'm not an expert, because if I change the src tag for anything online (e.g. the link to a picture on an Internet Server using http) the page created is able to fetch and exhibit the image properly.
Unfortunately I must be able to solve this problem without using any resource beyond the LAN to which the server and client browsers will be connected.
Thanks for any help.

You can add this piece of code in your server code to serve your images.
fs := http.FileServer(http.Dir("/path/to/images"))
http.Handle("/", fs)

Related

How to create a download link when opening a file from local file system

We are shipping some docu stuff on a cd and to have a better overview over all the files, we want to provide an index of all files as html, that can be put on the cd. The idea is that the user can download the wanted files just like from any webpage.
The problem is, that I can open the pdf in the browser but i want the download dialog to pop up if i click the button so I added the download="some-name.pdf".
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Demo</title>
<base href=".">
</head>
<body>
Download file
</body>
</html>
Using this via webserver (http) seems to work, but I cannot get it to work from the local file system...
To reproduce, just store the snipped in a file, create a folder "files" next to it and put any pdf file with an .html extension and name it test.pdf. Then open the page in a browser like Chrome or FireFox. (I am on a mac, but i guess it is the same for Windows or Linux?!)
Any help would be appreciated.

onenote snapshot intranet webpage

Is it possible to take a webpage snapshot of a non-public facing website (intranet) using the OneNote API?
I'm using the OneNote API to create OneNote notebooks, pages and sections. It's working well. Unfortunately, when I use data-render-src and point it to an intranet website, it fails to take a snapshot. The application is on the same intranet as the website I wish to capture.
Example HTML:
<!DOCTYPE html>
<html>
<head>
<title>A page with an image: Webpage capture zzzz</title>
<meta name="created" value="2015-11-11T12:45:00.000-8:00"/>
</head>
<body>
<p>This page displays an image of the webpage.</p>
<img data-render-src="https://intranet.website.com" width="800"/>
</body>
</html>
Note: I can take snapshots of publicly accessible websites.
Webpage snapshot description
https://learn.microsoft.com/en-us/graph/onenote-images-files#add-a-webpage-snapshot
Image rendered from html description
https://learn.microsoft.com/en-us/graph/onenote-images-files#add-an-image-rendered-from-html
I don't think it is - the OneNote aPI server will not have access to that page because it isn't public. You'll have to extract the HTML and send it over through the API instead of using data-render-src.

Html - Cannot load external http.jpg as image source

I want to load this external jpg in my webpage:
"http://ia.media-imdb.com/images/M/MV5BMjIxMjgxNTk0MF5BMl5BanBnXkFtZTgwNjIyOTg2MDE#._V1_SX300.jpg"
If I copy the link and put it in my chrome Browser, it opens the Poster.
But if I put it as a img src it does not load if I empty my cache before:
<!DOCTYPE HTML">
<html>
<head>
</head>
<body>
<img src="http://ia.media-imdb.com/images/M/MV5BMjIxNTU4MzY4MF5BMl5BanBnXkFtZTgwMzM4ODI3MjE#._V1_SX300.jpg" alt="no picture!" id="bild" height="400px"/>
</body>
</html>`
I get the following error:
Referral Denied
You don't have permission to access "http://ia.media-imdb.com/images/M/MV5BMjIxMjgxNTk0MF5BMl5BanBnXkFtZTgwNjIyOTg2MDE#._V1_SX300.jpg" on this server.
This sounds like they are checking the Referer: header sent by the web browser to determine whether the image is requested from one of their own web pages or from an external web page.
The IMDb Conditions of Use contains the following:
Framing: You may not frame or utilize framing techniques to enclose any trademark, logo, or other proprietary information (including images, text, page layout, or form) of IMDb without express written consent.
While you're welcome to link to IMDb's web pages (with appropriate attribution), I'm guessing that they don't want you to link directly to their images from your own web pages.

Add Excel file to HTML

I created a web page locally on my computer and have added an Excel file to it and am able to access it through a link I have given in the page. But when I uploaded it to 000webhost.com, which is a free server, they have file structure like:
root/public_html/
where one can upload there HTML or CSS files.
When I tried to add the Excel file by uploading it to a sub-directory of public_html (i.e; public_html/doc/), then it's not getting opened from the link in my page. That link was working perfectly when I checked my page by running it locally, that is without FTP.
I have checked everything for that a href link option...its not working.
My piece of code:
<html>
<HEAD>
<title> PLACMENT CELL </title>
</HEAD>
<body>
<div id="header">
<img src="top.jpg" width="1350" height="250">
</div>
click
</body>
Is this wrong or am I missing something?
<a href="http://gitplacment.comule.com/public_html/document/sheet001.htm">
assuming that
gitplacment.comule.com is your domain
and your created a sub folder under the root of your site, inotherwords, the folder where your index.html file is, should have a subfolder called document. And under that folder should be a file named, sheet001.htm.
then
<a href="http://gitplacment.comule.com/document/sheet001.htm">
would open the file
but I tried that url and it didn't work, so perhaps you have an issue with your DNS, I tried without your subdomain and a webpage did load
http://comule.com/document/sheet001.htm
so I would check your DNS settings.

Auto refresh in Mac not working for some site

I got a code that refreshes the html page as per the seconds I desire. I am on an Mac and I use the TextEdit app to make the HTML file. This code works for www.apple.com but it does not work for say, https://www.bitcointalk.org or http://www.macrumors.com.
I am not sure why this is happening. All I am doing is replacing the apple URL with bitcointalk url. I know I can also do this refreshing via Safari extension, but I need this code to work.
Thanks a lot
The code I am using is:
<html>
<head>
<meta http-equiv="refresh" content="5">
</head>
<FRAMESET>
<FRAME src="http://www.apple.com/">;
</FRAMESET>
</html>
EDIT: What I am trying to do is, create this html and move it to my iPhone, so that I can do the web refresh through my phone. Right now there are only paid apps in the App store that lets you refresh a page automatically every few seconds/minute and they are not really that good.
As #esqew pointed out in their comment, the sites that aren't showing up forbid access via frames by setting the X-Frame-Options HTTP header to DENY or SAMEORIGIN.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options