1

I am trying to deploy django web app on google cloud. I have tested on local machine and it appears to be working fine. But after I test it on google cloud port 80, the javascripts don't work.

Here is the django form where I am referencing the javascript function

class ScqQuestionForm(forms.ModelForm):
class Meta:
    model = Single_ans_q
    fields=['question_text']
    widgets = {
    'question_text' : forms.Textarea(attrs={
        'placeholder' : 'Question',
        'cols' : 140,
        'rows' : 6,
        'name':'questioninput',
         'id': 'questioninput' ,
         'onkeyup':'func_output()',
         'required': 'True',    



        })
    }

My javascript is

window.func_output = function () {
    button.disabled = true;
    output.innerHTML = input.value.trim();
    MathJax.texReset();
    MathJax.typesetClear();
    MathJax.typesetPromise([output]).catch(function (err) {
      output.innerHTML = '';
      output.appendChild(document.createTextNode(err.message));
      console.error(err);
    }).then(function () {
      button.disabled = false;
    });
  }

I get this error in the console

console error for javascript.

Further, in the console, I see my function

function in error console

The error only occurs on google cloud deployment, on local machines its running smoothly.

Manish
  • 3
  • 3

1 Answers1

1

Have you check if you open port 80?

dalmate
  • 462
  • 5
  • 13
  • Can you please guide how ? We page is getting rendered, but javascript is not working – Manish Aug 10 '20 at 09:52
  • Can you send me the link of your web app? – dalmate Aug 10 '20 at 10:24
  • To open the port 80, you need to create a firewall rule and assigning the rule to your VM instance with a `networking tag`. Additional information can be found in this doc: https://cloud.google.com/vpc/docs/using-firewalls – Bruno Aug 10 '20 at 15:50
  • Thanks. I opened the port 80 but JavaScript is still not working. How do i send you link for the app ? Will GitHub link be ok ? – Manish Aug 10 '20 at 16:34
  • Did you try to connect on the port 80 directly logged on the VM? perform a `curl localhost` on the port to test it. You could, at least, validate that your app is running on your VM! (Do you really run your code on a compute?) Another question: Can you share the code of your django config? – guillaume blaquiere Aug 10 '20 at 19:54