2

I'm using webapp2 and python 2.7 on my app engine application. However, I'm having a problem with the url on app.yaml.

I have my static files inside a static/ directory, in the root of my path. So inside of static/ I have static/scripts/MyScript.js

When I set app.yaml like:

application: myapp
version: 1
runtime: python27
threadsafe: true
api_version: 1

handlers:
- url: /.*
  script: myapp.app

- url: /static
  static_dir: static

libraries:
- name: webapp2
  version: latest

In my HTML code, the js is called like: <script src="static/scripts/Fuel.js"></script>

But, the file is not loaded, and I get a 404 error. (This problem happens also for .css files.)

However if I change the first url in app.yaml to:

handlers:
- url: /
  script: myapp.app

The static files are loaded, but when I try calling the routes url in my app, like an url I call in a form to save some data on server, this route is not found and I also get a 404 error.

Here is my routing code in myapp.py file.

app = webapp2.WSGIApplication(
                              [('/', MainHandler),
                              ('/save', SaveData),], 
                              debug=True)

So if I try to access myapp.appspot.com/save, it returns me a 404 error, saying:

The requested URL /save was not found on this server.

Any ideas? If you need more information about it, just ask on the comments.

Thanks.

4

1 回答 1

6

把你的全部 url /.* 放在底部,因为这是按顺序评估的。意思是在那之后它永远不会过去。

handlers:
- url: /static
  static_dir: static

- url: /.*
  script: myapp.app
于 2013-09-18T17:38:46.980 回答