简体   繁体   中英

Where are the static files located in google app engine?

If we create app engine with app.yaml and instructions:

- url: /static/(.*\.(css))
  static_files: sheet/\1
  upload: sheet/(.*\.(css))

- url: /static/(.*\.(bmp|gif|ico|jpeg|jpg|png))$
  static_files: img/\1
  upload: img/(.*\.(bmp|gif|ico|jpeg|jpg|png))

etc. My questions are:

  1. Where are these files uploaded? Can't find static folder with files in, data store or blob or admin, but engine is running and all files are accessible from URL.
  2. How to delete some files in static folder?
  3. How to delete all folders and start fresh?
  4. If we update to a new version (say 1.1) then what happens to the old version? Is it available or removed?
  5. Does creating an app engine as same version overwrite files?

This app engine is a big MYSTERY even PYTHON is an animal rarely found these days. Thanks.

Please find my answers inline :

  1. Where are these files uploaded?

ANS : These files are uploaded and kept by google at different location which is not accessible directly to you or your python script without using special directives in the app.yaml.

On the laptop/PC from where you upload your app, it would be in your app source directory but once uploaded, GAE stores it in a different way.

Such files, when mentioned in app.yam ( like you have done ), do not need any handlers ( python subroutines to open and serve them ). GAE has built in handlers to serve them. As you mentioned, you can access them in the same way as way as if they actually resided inside your app source directory.

  1. Can't find static folder with files in, data store or blob or admin, but engine is running and all files are accessible from URL. How to delete some files in static folder?

ANS : First part of this question is answered in Q1's answer.

To delete any of these files or directories, simply delete them ( or move them outside ) your app source directory on your laptop/PC. Then "Deploy" the app once for the changes to reflect in production app ( web ).

  1. How to delete all folders and start fresh?

ANS : Please see Q2 answer.

  1. If we update to a new version (say 1.1) then what happens to the old version? Is it available or removed?

ANS : If I understand it right, you mean to update your app's version in app.yaml file.

Those files remain intact irrespective of any code changes ( which you might call version upgrades of you app ). They would still be available and accessible in the same way.

  1. Does creating an app engine as same version overwrite files?

ANS : I believe you mean : "If I create a different source directory for this app from scratch. Add the code files but do not add the static files ( or directories ) and then "Deploy". Does my static files from the earlier deployment remain ? "

The answer is "no". This is because the GAE does not know if you created another directory from scratch or you deleted and made all changes to the existing one. And it does not matter for GAE or your app. As soon as you deploy the same app id from another source directory, for the same version of app, the code and static files of that source directory is all you have in the production app ( web ).

I hope it helps.

A bit more clarification is needed regarding question 2; for eg my app.yaml is :

application: app-id

version: 1

runtime: python27

api_version: 1

threadsafe: yes

default_expiration: "7d"

  • url: /video/(.*.mp4)

    static_files: video/\\1

    mime_type: video/mp4

    upload: video/(.*.mp4)

and directory video contains a file best.mp4, deployed and accessible via app-id.appspot.com/video/best.mp4, hence to remove:

I need to remove video directory (with best.mp4) and deploy removing

  • url: /video/(.*.mp4)

    static_files: video/\\1

    mime_type: video/mp4

    upload: video/(.*.mp4)

declarations from my app.yaml file

or

to add another mp4 file

I need to rename this new mp4 file as best.mp4 and deploy the app again??


CURRENT APP.YAML

application: app-id

version: 1

runtime: python27

api_version: 1

threadsafe: yes

default_expiration: "7d"

handlers:

  • url: /static/(..html)

    static_files: static/\\1

    upload: static/(..html)

  • url: /static/(..(css))

    static_files: static/\\1

    upload: static/(..(css))

  • url: /static/(..(bmp|gif|ico|jpeg|jpg|png))$

    static_files: static/\\1

    upload: static/(..(bmp|gif|ico|jpeg|jpg|png))

  • url: /static/(..(bmp|gif|ico|jpeg|jpg|png))$

    static_files: static/\\1

    upload: static/(..(bmp|gif|ico|jpeg|jpg|png))

  • url: /static/(..mp4)

    static_files: static/\\1

    mime_type: static/mp4

    upload: static/(..mp4)

  • url: .* script: main.app

libraries:

  • name: webapp2

    version: "2.5.2"


PREVIOUS APP.YAML (NOT SURE)

application: app-id

version: 1

runtime: python27

api_version: 1

threadsafe: yes

default_expiration: "7d"

handlers:

  • url: /static/(..html)

    static_files: static/\\1

    upload: static/(..html)

  • url: /static/(..(css))

    static_files: static/\\1

    upload: static/(..(css))

  • url: /static/(..(bmp|gif|ico|jpeg|jpg|png))$

    static_files: static/\\1

    upload: static/(..(bmp|gif|ico|jpeg|jpg|png))

  • url: /static/(..(bmp|gif|ico|jpeg|jpg|png))$

    static_files: static/\\1

    upload: static/(..(bmp|gif|ico|jpeg|jpg|png))

  • url: /(..mp4) (THIS CAUSED FILE TO APPEAR ON ROOT)*

    static_files: /\\1

    mime_type: /mp4

    upload: /(..mp4)

  • url: .* script: main.app

libraries:

  • name: webapp2

    version: "2.5.2"

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM