0

I'm trying to set up a RSS for my site. So I would like to make a link that takes in a keyword and produces a RSS feed.

I have a python script (script.py) to generate this xml, but I don't know how to run it and serve the text to the user when my page is called.

Essentially I would like to have someone visit mysite.com/<keyword> and be served the text generated in script.py

I can make the text appear to the user by simply running javascript, but this isn't being picked up by the rss.

<html>
<head>
  <title>Run Python Script</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

</head>
<body>
<script>
    $.ajax({
      method: "POST",
      url: "/script.py",
    })
      .done(function( response ) {
        var newXML = document.open("text/xml", "replace"); 
        newXML.write(response); 
        newXML.close(); 
      });
</script>
</body>
</html>

It seams like there should be some way of generating this text and serving it to the user, but I feel like I'm just missing something obvious

I'm using godaddy and cpanel if that helps

2
  • I think I have half the answer, I had to place it in the public_html/cgi-bin folder and make sure there was a .htaccess file, still working on taking in parameter Commented Apr 15, 2024 at 1:07
  • CGI is a lot simpler than it looks. It's literally just a set of environment variables. Your Python script just needs to inspect the PATH_INFO variable, in your example above it'll have the value <keyword>. See stackoverflow.com/questions/4939067/…
    – ckhan
    Commented Apr 15, 2024 at 8:18

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.