How to open HTML pages stored in CouchDB over the browser? - html

I am trying to view an HTML page that's saved as an attachment over the browser. When I navigate to the link, I get a prompt asking me to download the file. I want to open it directly in the browser. How do I do this?
Here's how I saved it:
curl -vX PUT http://localhost:5984/database/app/index.html -d index.html -H "Content-Type: application/html"

Related

Use cURL to pull data from Web into excel

Guys I'm currently working with cURL for the first time.
What I am trying to do is pull data from a website usimg cURL
an put them into excel using the following commmand. I have to use an API-Key
to get the data.
curl -H "X-API-Key: API_KEY_NUMBER" http://example.com/api/exports/model/62f0d0dc24757f6e5bb0b723 -o "text.xlsx"
This works fine so far, the problem is that if want to open it in Excel it tells me that the file can not be opened because the file format or the file extension is invalid.
If i change the file extension to
curl -H "X-API-Key: API_KEY_NUMBER" http://example.com/api/exports/model/62f0d0dc24757f6e5bb0b723 -o "text.txt"
it opens in a text file but with all the data that i need. Now I am looking for a way to solve this.

HTML file containing precompressed Brotli not encoding by Google server

I'm hosting a single page static website on Google cloud and I'm trying to implement text-compression on my index.html file.
What I've done so far was to copy all my minified html code from index.html and convert it to Brotli code using an online converter and then saving the Brotli code as index2.html in my bucket. Finally I set the Content-encoding meta value of index2.html to br.
How ever, despite my expectation, I only see a blank page in Chrome and "Content Encoding Error" in Firefox when i go to the www.mysite.com/index2.html address.
I also did the same procedure with gzip compression and setting the content-encoding to gzip but the results were the same. I used the following instructions by Google but it doesn't seem very comprehensive.
What am I doing wrong?
P.S. I am using HTTPS with a valid SSL. I also ckecked in my browser, and the server sent a header that includes the gzip and br in the content-encoding field.
It almost (!) works for me but not how I expect it to and I'm unclear why.
I have a (JPEG) file ${IMAGE} in a bucket that's hosting a website.
Copy the image locally
brotli it
Copy the brotli'd image back to the bucket
Set its metadata
Browse it.
gsutil cp gs://${BUCKET}/images/${IMAGE} ${PWD}
brotli ${IMAGE} --output=brotli.jpg
gsutil cp brotli.jpg gs://${BUCKET}/images
gsutil setmeta \
-h "Content-Type:image/jpeg" \
-h "Content-Encoding:br" \
gs://${BUCKET}/images/brotli.jpg
gsutil stat gs://${BUCKET}/images/brotli.jpg
Content-Encoding: br
Content-Type: image/jpeg
If I browse the site directly in Chrome, it fails (canceled) no response code:
ERR_CONTENT_DECODING_FAILED
If I browse the GCS public URL, it works (200):
https://storage.googleapis.com/${BUCKET}/images/brotli.jpg
And:
https://storage.cloud.google.com/${BUCKET}/images/brotli.jpg
If I use gzip rather than brotli, both work as expected.
For some reason, I'm unable to browse a brotli compressed file as part of the static site even though it's definitively present and I can browse the URL via other means.

How can I download file instead of view in Google cloud storage using html

I want to download files instead of view in Google cloud storage using HTML.
<a
href="https://storage.googleapis.com/test/test.pdf"
download
>download</a
I'm not able to download the pdf. It's open in the browser.
You need to update the Metadata content-type of your file to application/octet-stream.
gsutil -h "Content-Type: application/octet-stream" \
gs://test/test.pdf
Like this, the browser won't be able to detect the file type and to open the PDF Viewer. So, the browser will propose you to save it on your computer.
Note: if there is a way to do a similar thing in HTML, it could be good. But I don't know, I'm not good in frontend dev

How to remove .html extension in URL on google cloud platform (storage bucket) hosted site? [duplicate]

I'd like to let website users load userProfile.html when they request www.website.com/userProfile (without .html).
There is nothing about that in docs.
You can serve HTML content without a .html suffix. It's important to set the content-type though. For example, with gsutil:
gsutil -h "Content-Type:text/html" cp /path/users/userProfile \
gs://www.website.com/userProfile

cURL post data to server and get redirected page

I am trying to build a program to login to a webpage, load up the homepage while logged in, and collect some data to use elsewhere. I can successfully login and collect the JSON response, but I want to load up the homepage in the same request and collect the data. Here's my code so far:
curl -L -XPOST "https://www.ifit.com/api/user/login" -d "email=emailaddress#gmail.com&password=passwordhere&rememberMe=false"
What do I do?
Assuming the homepage path you are referring to is /api/user/homepage then a one line command would look something like this:
curl -L -XPOST "https://www.ifit.com/api/user/{login,homepage}" -d "email=emailaddress#gmail.com&password=passwordhere&rememberMe=false"
Since you are accessing an API, which usually isn't done via browser, you won't likely have to deal with cookies as the server should be authenticating you by other means such as an Authorization header or Access token. You may have to extract that from the login response and pass it along in any subsequent requests with the -H option, which you won't be able to do in one single command unless your client has already been authenticated and that token has not expired.