项目作者: Satyabrat35

项目描述 :
Project as a part of Hasura Winter Internship
高级语言: HTML
项目地址: git://github.com/Satyabrat35/MapBox-HPDF.git
创建时间: 2018-01-23T18:45:10Z
项目社区:https://github.com/Satyabrat35/MapBox-HPDF

开源协议:

下载


MapBox

Hasura project on Mapbox Geolocation API

Getting started

Follow these steps to get started with development using this project

  1. hasura-cli

In order to get started with development you have to install the hasura cli.To install copy this code to your terminal

  1. $ curl -L https://hasura.io/install.sh | bash

Once installed login to hasura using

  1. $ hasura login

A login page would open up in your default browser , sign up or login to access the hasura dashboard. Clone the project by copying the following code to your terminal

  1. $ git clone https://github.com/Satyabrat35/MapBox-HPDF.git

Prerequisites

Directory structure

The flask microservice is located in microservices/app directory in your Hasura project with the following structure:

  1. .
  2. ├── Dockerfile # instructions to build the image
  3. ├── k8s.yaml # defines how the app is deployed
  4. ├── conf
  5. └── gunicorn_config.py # configuration for the web server
  6. └── src
  7. ├── static
  8. └── css # contains css files for adding styles
  9. └── js # contains basic javascript files for authentication purposes
  10. ├── templates
  11. └── html files # contains static html files compiled with Jinja2 template
  12. ├── config.py # some utilities to configure URLs etc
  13. ├── __init__.py # main Flask app is defined here
  14. ├── requirements.txt # python dependency requirements
  15. └── server.py # main Flask server code

Local development

With Hasura’s easy and fast git-push-to-deploy feature, you hardly need to run your code locally.
However, you can follow the steps below in case you have to run the code in your local machine.

Without Docker

It is recommended to use a Virtual Environment for Python when you are running locally.
Don’t forget to add these directories to .gitignore to avoid committing packages to source code repo.

  1. # setup pipenv or virtualenv and activate it (see link above)
  2. # go to app directory
  3. $ cd microservices/app
  4. # install dependencies
  5. $ pip install -r src/requirements.txt
  6. # Optional: set an environment variable to run Hasura examples
  7. $ export CLUSTER_NAME=[your-hasura-cluster-name]
  8. # run the development server (change bind address if it's already used)
  9. $ gunicorn --reload --bind "0.0.0.0:8080" src:app

Go to http://localhost:8080 using your browser to see the development version on the app.
You can keep the gunicorn server running and when you edit source code and save the files, the server will be reload the new code automatically.
Once you have made required changes, you can deploy them to Hasura cluster.

Microservices

Contains the microservices created by the user in the project. Each microservice has a route which is of the format

  1. <microservice-name>.<cluster-name>.hasura-app.io

Create a microservice

To create a microservice use the following commands:

To list a number of templates for creating a microservice

  1. $ hasura microservice template-list

To create a microservice

  1. $ hasura microservice create <ms-name> --template=<template-name>

Add routes for the microservice

  1. $ hasura conf generate-route <ms-name> >> conf/routes.yaml
  2. $ hasura conf generate-remote <ms-name> >> conf/ci.yaml

To know more read the hasura docs