Giter Club home page Giter Club logo

api.mozillascience.org's Introduction

api.mozillascience.org

django API application for mozillascience.org

Build Status

Getting started

To start working with the API server locally, you will need to make sure you have the following prerequisite dependencies installed.

  1. git
  2. Docker

Important note: You will have to make sure that you have successfully run the Docker Quickstart Terminal to get the DEFAULT VirtualBox configured to start working locally.

To verify that you should see this nice little graphic:


                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/

Once you have both dependencies installed, you can start by forking and cloning the project to your local machine.

git clone https://github.com/mozilla/api.mozillascience.org.git

Running your application

Here are a list of commands you can run that are relevant to working with this project.

If you are on a UNIX-based system, run each command using:

sh run.sh <command_name>

where <command_name> should be replaced by one of the commands in the table below.

If you are on a Windows system, run each command using:

run.bat <command_name>

where <command_name> should be replaced by one of the commands in the table below.

To just start up the application, refer to command 2 below

No. Command Description
1. env Setup your environment with the default configuration.
2. Start the application by not passing in a command name. Remember to run the env command first before this.
3. test Run tests for this project.
4. makemigrations Create migration files to reflect model changes. Run this whenever you make changes to a model.
5. migrate Apply migrations to the database.
6. shell Open up a Bash shell in the docker container to run shell commands.
7. pyshell Open up a Python interactive shell in the docker container.
8. createsuperuser Create a super user for the Django administrative interface.
9. schema-image Generate a database schema visualization and add it to your file tree in the app folder as db_schema.png. This is automatically done when you run the makemigrations command.

Environment Variables

Variable Value About
GH_TOKEN String Optional, token only required if you are going to be using it extensively.
DATABASE_URL URL Required: URL to your postgres database e.g. postgres://<USER>:<PASSWORD>@<HOSTNAME>:<PORT>/<DBNAME>
DJANGO_SECRET_KEY String Required: anything that is something people can't guess!
DEBUG Boolean Required: True or False
CORS_WHITELIST String Optional, comma separated list of domains (without space), e.g. google.ca,.herokuapp.com. For allowing all domains, set to *
CORS_REGEX_WHITELIST String Optional, comma separated list of domain regex patterns (without space), e.g. ^(https?://)?(\w+\.)?google\.com$,\.herokuapp\.com$

Running python commands

Sometimes you will need to run a specific python/django command in the container, to accomplish this you will need to run:

docker-compose run web <your command here>

NOTE: Replace <your command here> with an actual command, for example: docker-compose run web echo 'hello world'

Generating a visualization of the database schema

To generate an image representing the schema of the database (which creates a db_schema.png file in the app directory) run the following command:

sh run.sh schema-image

or on Windows:

run.bat schema-image

NOTE: Whenever you make a change to a model and create a migration for it, the schema visualization is automatically updated. Remember to commit these changes.

Deployment

The API server uses Heroku for its deployment services, and the current workflow is that every push to master will deploy a new version of this app to the staging server on heroku (assuming travis CI passes before it deploys). The production server is deployed from the staging server using the Heroku Pipelines to promote to production.

api.mozillascience.org's People

Contributors

abbycabs avatar akshatnitd avatar alicoding avatar auremoser avatar gideonthomas avatar hassenpy avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.