Damir Shaykxutd
Damir Shaykxutd

Reputation: 29

Pyscript AttributeError module has no attribute

I want create a custom module with pyscript

#!/var/www/u0745362/data/env/bin/python
import cgi

print("Content-type: text/html\n")

def hello():
   print("ok!!!")

when i'm run by url, took -> AttributeError: module 'example' has no attribute 'hello'

<!doctype html>
<html>
<head>
<script defer src="https://pyscript.net/releases/2022.12.1/pyscript.js"></script>
<link rel="stylesheet" href="https://pyscript.net/releases/2022.12.1/pyscript.css"/>
</head>
<body>    

<py-config>
  [[fetch]]
  files = ['example.py']
  from = '../wp-content/themes/codetheme/py/'
</py-config>
<py-script>
  import example
  example.hello()
</py-script>
</body>
</html>

but if i'm creating second file without pyscript import module from example.py and i'm going by url (for example https://domain_name/wp-content/themes/codetheme/py/example1.py) it works and i see on screen -> ok!!!

#!/var/www/u0745362/data/env/bin/python
import example
example.hello()

Upvotes: 0

Views: 241

Answers (0)

Related Questions