I am trying to setup PythonAnywhere with a simple Python app but the WSGI config doesn't seem to be able to import properly, what am I doing wrong?
#!/usr/bin/python3.6
import web
import urllib
from xml.dom import minidom
... [code] ...
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
#app.wsgifunc()
and my WSGI is as follows
#!/usr/bin/python3.6
import sys
path = "/home/myUsername"
if path not in sys.path:
sys.path.append(path)
from myPythonFileNameInSameDir import app as application
application.wsgifunc()
PythonAnywhere dev here -- when you import your web.py app from the WSGI file, it won't run anything in the if __name__ == "__main__":
section.
You need to do this in the app:
#!/usr/bin/python3.6
import web
import urllib
from xml.dom import minidom
... [code] ...
app = web.application(urls, globals())
if __name__ == "__main__":
app.run()
...and this in the WSGI file:
#!/usr/bin/python3.6
import sys
path = "/home/myUsername"
if path not in sys.path:
sys.path.append(path)
from myPythonFileNameInSameDir import app
application = app.wsgifunc()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.