Jump to content
Sign in to follow this  
kaotkbliss

Convert localhost to absolute local path

Recommended Posts

We make a lot of apps with a web page interface for various departments in the company to use. When writing or making changes to an app, we usually run the server code locally for testing changes.

My boss wants me to automate this process by using Postman to send a set group of variables to the locally running server code, then compare the returned pdf with a control pdf to make sure they are still identical.

Since the server code is running locally, it's hosted on "localhost:port" but javascript can't read a file at a path "localhost:port//somename.pdf" so I need to convert localhost:port to the absolute path where the local server script is actually running. Is there a way to do this?


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

try to use 127.0.0.1


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

I started on a different route by using the http module to "download" the file to where I could use __dirname + /somepath then work with it from there.

But now I'm having issues with trying to get the file hash/checksum

I have a control pdf, which is the result of test variables being plugged into the app. whenever changes are made to the app, the new pdf with the same variables plugged in should still be exactly the same as the control pdf

I've been messing around with crypto, but that seems to include the filename and the path in the hash it generates for the file, so it never matches.

Also, when I changed 1 variable and created a new pdf, it's hash doesn't change, although I'm pretty sure it should since the contents of the pdf changed.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

So the problem with the hash is that the software we use that outputs pdfs doesn't create them binarily (is that a word?) identical using the same variables so each time a pdf is created it gets a new hash.

I was able to get around this by using the pdf2json module and grabbing the rasterization of each page, then comparing each array from both pdfs.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...