I have problem with using template in Google App Engine by Python.
the thing is, when I address my static folder in Yaml, I can NOT access to my template and when I remove it, it is access able. look at the files.
this is my file structure
-src\
----\calc.py
----\main.py
----\index.html
----templ\
---------\calc.html
---------\js
---------\css
YAML:
handlers:
- url: /.* script: main.py
MAIN.PY
def main():
application = webapp.WSGIApplication([
('/', MainPage),
('/calc',Calc)
], debug=True)
wsgiref.handlers.CGIHandler().run(application)
Calc.py
class Calc(webapp.RequestHandler):
def get(self):
temp = os.path.join(os.path.dirname(__file__), 'templ/calc.html')
outstr = template.render(temp, temp_val)
self.response.out.write(outstr)
THE RESULT IS :
Status: 200 OK
Content-Type: text/html; charset=utf-8
I can reach my file and the template addressing is working
BUTTTTTTT
when I add the following line to my YAML to access to my css and js and so on. IT is not access able
YAML:
handlers:
- url: /.*
script: main.py
- url: /templ
static_dir: templ
or If i change order of them :
YAML:
handlers:
- url: /templ
static_dir: templ
- url: /.*
script: main.py
BOTH are NOT working and there is my error
Status: 500 Internal Server Error
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
handler.get(*groups)
File "/Users/em/Documents/workspace/NerkhARZ/src/calc.py", line 26, in get
outstr = template.render(temp, temp_val)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/template.py", line 88, in render
t = load(template_path, debug)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/template.py", line 185, in load
return _load_user_django(path, debug)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/template.py", line 110, in _load_user_django
template = django.template.loader.get_template(file_name)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_0_96/django/template/loader.py", line 79, in get_template
source, origin = find_template_source(template_name)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_0_96/django/template/loader.py", line 72, in find_template_source
raise TemplateDoesNotExist, name
TemplateDoesNotExist: calc.html
Please help me through this, there must be simple solution for it. I really dont believe that GAE is that much fool….
Thank you in advanced
Files designated as static in
app.yamlare not available to application code in the python runtime. They are only served directly the the user’s browser in response to requests matching the regular expression inapp.yaml.Do not mark templates as static. Only files that should be served as-is to the user, such as javascript, CSS, and images, should be marked as static.