when i was about to write a sub module for my app, i'd like to put all the stuffs in a sub folder like /foo
, and i give the script the name foo.py
and in it there's a
app = webapp2.WSGIApplication([('/foo/', Index)])
then it comes to
Fatal error when loading application configuration:
threadsafe cannot be enabled with CGI handler: foo/foo.app
in "/home/***/workspace/***/app.yaml", line 23, column 20
then i set it to false, it becomes error 500
ImportError: Could not find module foo.foo.app
my app.yaml
is like
application: ***
version: alpha
runtime: python27
api_version: 1
threadsafe: false
handlers:
- url: /static
static_dir: static
- url: /admin.*
script: admin.app
login: admin
- url: /foo
script: foo/foo.app
- url: /.*
script: index.app
finally i solved like this:
__init__.py
in the folderfoo/
, leave it empty.foo/foo.app
tofoo.foo.app
and it seems has nothing to do with
threadsafe
, i changed it totrue
and it's still working.In order to flag your folder as a package in python, the only thing you have to do is to create an empty
__init__.py
file in that folder (note two underscores on both sides of init).Then in order to use your code from another file, you have to import the relevant file.
import foo
where foo stands for your filename in your folder (foo.py)The foo folder must be a python package so as to work. Thus, just add an
__init__.py
inside it and it should be ok.