Installer for the SERVIR App Template
Project description
SERVIR App Template Installer
This installer will help you get the SERVIR app template installed quickly and ready to modify.
Required
- Anaconda (Miniconda may also work)
- Python: 3.9
- Google account
- git (must also be in system path)
Installation
Create a conda environment for the installer
conda create -n app-template python=3.9
Activate environment
conda activate app-template
Install servir_template_cli
pip install SERVIR-Template-CLI
cd to a directory where you would like to start the application. I recommend this be a common development directory. You will create the specific directory with your project name in the next few steps. My directory where I start all of my web apps is named websites.
cd path/to/your/websites/directory
Install the app template using servir_template create command and passing -n with the name you would like for your application. This will create the directories, files, and the new conda environment for the application. It will take several minutes to complete creating the conda environment and give little information when Solving environment step is happening. When this step is done it will continue automatically and install all packages that you need, as well as apply all database setup actions.
servir_template create -n name_ur_app_here
Your application has now been created inside the directory of the name you provided above. Enter the directory to continue.
cd name_ur_app_here
Before editing the application you will need to have an Earth Engine (EE) account, and a Google cloud project where you will enable both EE and Google Authentication. To do that follow these steps:
- If you do not currently have an EE account sign up https://earthengine.google.com/signup
- Next you will need to create a google cloud project where you will enable EE and Google Authentication for your project. Navigate to https://console.cloud.google.com/projectcreate
- Follow the prompts to create the project, you may want to name it Your_Project_Name so you can skip this part when you set up your application.
- After you create the project you must select it from the dropdown in the top
- In the left panel under APIs & Services click the "OAuth consent screen" link, then fill out the form with the information for your application. There are a few pages with choices, proceed when finished.
- In the left panel click "Credentials" link
- At the top left click + Create Credentials and select "OAuth 2.0 Client ID"
- In the dropdown select "Web Application" and give a name.
- In the App Domain fields use the the dev domains for example:
- Add Authorized JavaScript origins (you may enable multiple)
- Examples:
- http://localhost:8000
- http://127.0.0.1:8000
- https://your_domain
- Examples:
- Add Authorized redirect URIs (you may enable multiple)
- Examples:
- http://localhost:8000/accounts/google/login/callback/
- http://127.0.0.1:8000/accounts/google/login/callback/
- https://your_domain/accounts/google/login/callback/
- Examples:
- Copy and save the Client ID and Client secret to your local machine (you will need these later)
- Click DOWNLOAD JSON and save
- Click save
- Click Enabled APIs & Services then click the + Enable APIS AND SERVICES link at the top
- Search for Earth Engine, click it, then click enable.
- Click Create Credentials again and select service account
- Fill out information and click CREATE AND CONTINUE.
- Click Select a role and scroll to Earth Engine, then select Earth Engine Resource Viewer
- Register the service account https://signup.earthengine.google.com/#!/service\_accounts
That was the hard part, everything else is easy to get you up and running. Back to your files, you should be in the project directory, if not, navigate there to edit the data.json file.
Edit data.json
This file contains private information that you do not want to share with the world. It is ignored in the .gitignore so when you push your application to github it will not go with the rest of your files. It is a json structure that looks like the following.
{
"ALLOWED_HOSTS": [
"localhost",
"127.0.0.1"
],
"CSRF_TRUSTED_ORIGINS": [
"http://localhost:8000",
"http://127.0.0.1:8000"
],
"DATA_DIR": "path_to_data_directory",
"SECRET_KEY": "{yx+Z9or:Yuisk>:&R%-NZ%oUk@BB!XAL#?RZay=^U>MDY?Qj=e^-YT3u^dp):~|",
"private_key_json": "path_to_key_file_from_google_console",
"sample_netCDF": "https://thredds.servirglobal.net/thredds/fileServer/mk_aqx/geos/20191123.nc"
"service_account": "registered_ee_service_account_associated_with_key"
}
To begin you will need to enter the path to your key file that you created in the Google console, where it says path_to_key_file_from_google_console. If you are using a Windows machine be sure to use double slashes.
For DATA_DIR, create a separate directory some place, usually out of the actual application directory to store data. Replace path_to_data_directory with that path. To use the example in the template you will need to create a subdirectory named geos, and download https://thredds.servirglobal.net/thredds/fileServer/mk_aqx/geos/20191123.nc to the directory.
Replace registered_ee_service_account_associated_with_key with the email address of the Google service account.
Save the data.json file
Activate your applications conda environment
conda activate name_ur_app_here
create superuser
run the following command and follow the prompts
python manage.py createsuperuser
Start the App
python manage.py runserver
- Open a browser and navigate to http://127.0.0.1:8000/admin/
- Click Social applications
- Click ADD SOCIAL APPLICATION
- Select Google in the provider
- Enter your application name in name
- Enter the Client id from the Google console
- Enter the Secret Key from the Google console
- Leave Key empty
- Select 127.0.0.1 and hit the arrow to move it to Chosen sites
- Click Save and continue editing
- If 127.0.0.1 is not still in Chosen sites repeat step 9 and 10.
- Click VIEW SITE at the top right of the screen
At this point all examples should work.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file SERVIR_Template_CLI-0.0.40.tar.gz
.
File metadata
- Download URL: SERVIR_Template_CLI-0.0.40.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e218c14cf192cb3879c654c68378882bb1402951b1df68bd9e7133defce57401 |
|
MD5 | 1e9308aed25a4aec6cc02acdf4769c71 |
|
BLAKE2b-256 | 41c29da2a1b1e4367877cb0f6c429e925bea6babff1f28cea2bdd730d2d80cce |
File details
Details for the file SERVIR_Template_CLI-0.0.40-py3-none-any.whl
.
File metadata
- Download URL: SERVIR_Template_CLI-0.0.40-py3-none-any.whl
- Upload date:
- Size: 12.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e1edaeb5909a5448cd12e8dced56a88199c6b597ea84ba2912a9c86752af403 |
|
MD5 | b398d8db1308165b77ab989f51ca133e |
|
BLAKE2b-256 | 6acef0f766c2401220c26bab52eda61c0671696f399ee563665d16598c770290 |