Skip to main content

Installer for the SERVIR App Template

Project description

SERVIR App Template Installer

Python: 3.9 License: MIT SERVIR: Global

This installer will help you get the SERVIR app template installed quickly and ready to modify.

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.

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:

  1. If you do not currently have an EE account sign up https://earthengine.google.com/signup
  2. 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
  3. 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.
  4. After you create the project you must select it from the dropdown in the top
  5. 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.
  6. In the left panel click "Credentials" link
  7. At the top left click + Create Credentials and select "OAuth 2.0 Client ID"
  8. In the dropdown select "Web Application" and give a name.
  9. In the App Domain fields use the the dev domains for example:
    1. http://127.0.0.1:8000/
    2. http://127.0.0.1:8000/terms-privacy
    3. http://127.0.0.1:8000/terms-privacy
  10. Add Authorized JavaScript origins (you may enable multiple)
    1. Examples:
      1. http://localhost:8000
      2. http://127.0.0.1:8000
      3. https://your_domain
  11. Add Authorized redirect URIs (you may enable multiple)
    1. Examples:
      1. http://localhost:8000/accounts/google/login/callback/
      2. http://127.0.0.1:8000/accounts/google/login/callback/
      3. https://your_domain/accounts/google/login/callback/
  12. Copy and save the Client ID and Client secret to your local machine (you will need these later)
  13. Click DOWNLOAD JSON and save
  14. Click save
  15. Click Enabled APIs & Services then click the + Enable APIS AND SERVICES link at the top
  16. Search for Earth Engine, click it, then click enable.
  17. Click Create Credentials again and select service account
  18. Fill out information and click CREATE AND CONTINUE.
  19. Click Select a role and scroll to Earth Engine, then select Earth Engine Resource Viewer
  20. 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.

{
  "SECRET_KEY": "{yx+Z9or:Yuisk>:&R%-NZ%oUk@BB!XAL#?RZay=^U>MDY?Qj=e^-YT3u^dp):~|",
  "ALLOWED_HOSTS": ["localhost", "127.0.0.1"],
  "CSRF_TRUSTED_ORIGINS": ["http://localhost:8000", "http://127.0.0.1:8000"],
  "private_key_json" : "path_to_key_file_from_google_console",
  "DATA_DIR" : "path_to_data_directory",
  "service_account" : "registered_ee_service_account_associated_with_key",
  "sample_netCDF": "https://thredds.servirglobal.net/thredds/fileServer/mk_aqx/geos/20191123.nc"
}

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%5C_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
  1. Open a browser and navigate to http://127.0.0.1:8000/admin/
  2. Click Social applications
  3. Click ADD SOCIAL APPLICATION
  4. Select Google in the provider
  5. Enter your application name in name
  6. Enter the Client id from the Google console
  7. Enter the Secret Key from the Google console
  8. Leave Key empty
  9. Select 127.0.0.1 and hit the arrow to move it to Chosen sites
  10. Click Save and continue editing
  11. If 127.0.0.1 is not still in Chosen sites repeat step 9 and 10.
  12. Click VIEW SITE at the top right of the screen

At this point all examples should work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SERVIR_Template_CLI-0.0.6.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SERVIR_Template_CLI-0.0.6-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file SERVIR_Template_CLI-0.0.6.tar.gz.

File metadata

  • Download URL: SERVIR_Template_CLI-0.0.6.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for SERVIR_Template_CLI-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ba0a3c014fbe6153e71f7b4cdfe0908f43ce6bec1d3cf0943b554ee7c9ab5bea
MD5 5b42273c6cd9827bc4eab920b20a424b
BLAKE2b-256 2ba8d00e27c2db01e464fc2653410ff729806e4672f6858427b92e31a6a7e121

See more details on using hashes here.

File details

Details for the file SERVIR_Template_CLI-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for SERVIR_Template_CLI-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5edc662ea0d415f2002705680b36f9e24b20ddaf8cf206026efd34f2c3725de1
MD5 9272fb16ec6a9d10e7c473ddc2f1aa35
BLAKE2b-256 a00c960c20d5112cb4436dada7fff694885346c5b4ae7019609024751c1a60d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page