Web redirect on a server api written in python

Hey guys,

Is it possible that he python code that we can already host as backendless api calls,
will make a redirect to another page, for example the app google play store page?

thanks,
Tal

Hi Tal,

Backendless currently cannot execute Python scripts.

Regards,
Mark

right,
will redirecting be possible through php or java?

I would need to know more details about the use-case. Such as where the original request is made from? Is it HTTP/S ? What is expected in response?

we need https
the original request is made from a device or possibly another redirect prior to our redirect from another source (ad network).

nothing is expected in response, just a redirect to google play

It might be possible with our hosted scripted (nodejs code deployed to the /web/scripts file directory). I will ask a developer to look into it and respond.

I’m not sure I understand.
We need the functionality, and thought that a service api, like already implemented in backebdless could do the work

You can do it with the following script in File Service’s web/scripts directory:

exports.run = function ( request, response )
{
    response.writeHead( 301, { Location: 'https://api.backendless.com/' } );
    response.end();
};

where you substitute api.backendles.com with your destination.

  1. how would be the url of this then

  2. is it not possible with a Business logic hosted api service?

http://support.backendless.com/public/attachments/0b8859817abfb09117dfee7472767550.png</img>

The URL will be the file’s (script’s) public URL in file service.

It won’t be possible in hosted services since you have no control on the response object there.

I tried creating a file named redirect.js, pasted the lines you wrote, copied the url and pasted it in chrome and got this:
https://api.backendless.com/AF8A6FD1-7119-6D55-FF83-BC9AA0072B00/v1/files/web/scripts/redirect.js

Error: Cannot find module ‘/repo/web/scripts/redirect.js’

the same happened with the default hello.js file in the scripts:
https://api.backendless.com/AF8A6FD1-7119-6D55-FF83-BC9AA0072B00/v1/files/web/scripts/hello.js

Hi Tal,

I have escalated it to the dev team, this is certainly does not look/work right…

Mark

Thank you Mark

Hi Tal,

Sorry for the inconvenience, it was a configuration problem in our subsystem. Everything works fine now, please verify.

Hey Sergey,
Trying to use the code you wrote for redirect. it doesn’t work:
exports.run = function ( request, response )
{
response.writeHead( 301, { Location: ‘https://www.youtube.com/’ } );
response.end();
};
here is a link to the code:https://api.backendless.com/AF8A6FD1-7119-6D55-FF83-BC9AA0072B00/v1/files/web/scripts/redirect.js
Best,
Tal

Yes, I see the problem now. We shall fix it in a few days and I’ll notify you here. Thanks for the patience!

Thanks

Should work as expected now, please verify

yes It works.

also, can we make inserts to our Backendless Data tables from this javascript file?
so it will both redirect and also insert a row to one of our tables.

Hey, waiting for a response:

“can we make inserts to our Backendless Data tables from this javascript file?so it will both redirect and also insert a row to one of our tables.”

if no, is there any other way with Backendless to both redirect to another URL and perform a able insert?