Because GAE in the domestic visit inconvenient, so there are some small applications, I will put on the SAE above, although the SAE has a lot of flaws, but it is easy to get started, at least the documentation is good.
Development of applications on the SAE, I generally use flask,sae pre-installed Flask, so you can use directly, but we will inevitably use some non-preloaded libraries.
If it was in the past, you might need to copy the package to the app directory yourself, and then load it manually, now, no need to be so troublesome, SAE has a very good solution, see "Install dependent third party package"
You can use Saecloud instead of PIP to install a third-party library
Saecloud Install-r Requirements.txt
This command installs the third-party library under the Site-packages directory of the application directory, where all dependencies can be packaged into a zip archive, so that it is easy to upload and maintain.
CD Site-packages/zip-r. /site-packages.zip.
Load these dependencies in the Index.wsgi
Import Osimport sysroot = Os.path.dirname (__file__) # Take one of the two Sys.path.insert (0, Os.path.join (root, ' site-packages ')) Sys.path.insert (0, Os.path.join (root, ' site-packages.zip '))
Although it is one of the two, it is recommended to use a ZIP file.
One problem is that we need to pack, but the SAE does not have pre-packaged packages, but our local development also relies on Flask these preinstalled packages, all using Saecloud installation, this package will obviously have redundancy.
Drawing on the benefits of Bower, NPM, and the dependency management of these package managers, it is clear that we should separate the dependent libraries.
# Install non-preloaded dependent pip install-r requirements.txt# Maintenance Pre-installed dependency Saecloud install-r Requirements-dev.txt
This way, only the packages in the Requirements.txt will be installed in the Site-packages folder in the app directory.
After some practice, I have organized myself with the more comfortable source code file structure
The code is as follows:
LICENSE
Makefile
Readme.md
Requirements-dev.txt
Requirements.txt
Site-packages
...
Site <---web App directory
Index.wsgi
main.py
Config.yam
Site-packages.zip <---packaged dependent libraries
...
I will add the following files to the. Gitignore to prevent them from being submitted to the version.
The code is as follows:
/site-packages
/site/site-packages.zip
/site/index.wsgic
To facilitate the installation of dependencies and deployment projects, I wrote a Makefile