0

everyone.I wanna include javascript in the html(webpy templates),but it doesn't work.the javascript code in the html works very well...

following is the main python file(main.py):

urls = ('/main','main')
render = web.template.render('templates/')

class main:
  def GET(self):
    return render.main()

app = web.application(urls,globals())

if __name__ == "__main__":
  app.run()

templates/main.htm:

<body>
<script type="text/javascript" src="include.js"></script>
<script>
  alert(location.href);  //this line works..
</script>
</body>

include.js:

alert('test');  //this line doesn't work

1 Answer 1

2

You must put the include.js file in a "static/js" directory at the root of your project and src should be "static/js/include.js".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.