Search code examples
google-app-enginewebapp2

Can you overlap a static-directory and a dynamic route in webapp2?


For example if I have a physical directory with the name "files" and a static file called "file.html" but I also want to have a dynamic handler called "/files/hello_world".

How do you configure the app.yaml file to handle this case, so the static file loads and so does the handler?

Thanks!


Solution

  • So I handled it like this:

    - url: /files/(.*\.(html|jsp|js|css|map|woff|png|jpg|jpeg|gif|tiff))$
      static_files: files/\1
      upload: files/(.*\.(html|jsp|js|css|map|woff|png|jpg|jpeg|gif|tiff))$
    
    - url: /.*
      script: main.app
      secure: always
    

    So now /files/index.html works and so does /files/do_something_dynamic

    Thanks for the help!