You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 7, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+76-30
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,46 @@
2
2
3
3
A simple map-based application for estimating the power potential of microhydropower installations.
4
4
5
-
## Software
5
+
## Architecture Overview
6
6
7
7
The Bard Microhydropower Calculator is built with Python-Flask, Leaflet, Esri-Leaflet, Bootstrap, and jQuery. Data and Geoprocessing services are from the Esri Living Atlas in ArcGIS Online (AGOL).
8
8
9
-
### Development Quickstart
9
+
Python Flask provides a server-side framework for assembling the web application from templates and assets. Since this is a single page app, it doesn't have much to do in that regard. Rather, its role is primarily to serve as a proxy for authenticating into secured Esri ArcGIS Online (AGOL) resources. It retrieves an AGOL authentication token on page load and returns it to the client side code (javascript), where it is used to make calls to elevation and other data services from Esri.
10
+
11
+
On the front-end:
12
+
13
+
* Bootstrap and jQuery provides the stack for the mobile-adaptive layout
14
+
* Leaflet is used for the map
15
+
* Esri-Leaflet helps utilize Esri services in conjunction with the Leaflet map
16
+
17
+
Front-end business logic is written in javascript with only jQuery. Javascript and CSS compliation and bundling is being handled by GulpJS and Browserify.
18
+
19
+
## Development
20
+
21
+
### Configuration (`config.py`)
22
+
23
+
The application requires a few global configuration variables to be set, mainly to enable access to 3rd-party services.
24
+
25
+
See `app/config.py` for more information.
26
+
27
+
_to be completed._
28
+
29
+
#### ArcGIS Application Registration
30
+
31
+
* Esri Application ID
32
+
* Esri Application Secret
33
+
34
+
#### Mapbox Token
35
+
36
+
* Token
10
37
11
-
This application requires Python 3.4 or later. Client-side javascript dependencies are included with the repository, so no javascript build system (e.g., Node/NPM) is currently necessary. However that _should_ change in the future; more on that later.
38
+
### Quickstart
12
39
13
-
This quickstart assumes you have:
40
+
To develop this, you must have installed:
14
41
15
-
* a working installation of Python 3.4+,
16
-
* you can call `python` and `pip` or (`python -m pip`) from the command line
42
+
* Python 3.4+, and you can call `python` and `pip` or (`python -m pip`) from the command line
43
+
* Node/NPM and you can call `node` and `npm` from the command line
44
+
* GulpJS installed (available via `npm`)
17
45
*`git` installed, also available from the command line.
Navigate to [http://localhost:5000](http://localhost:5000) to see the site.
94
+
This will download and install a whole lot of javascript in a `node_modules` folder.
57
95
58
-
### Architecture
96
+
2. Run a browser-synced development server
59
97
60
-
Python Flask provides a server-side framework for assembling the web application from templates and assets. Since this is a single page app, it doesn't have much to do in that regard. Rather, its role is primarily to serve as a proxy for authenticating into secured Esri ArcGIS Online (AGOL) resources. It retrieves an AGOL authentication token on page load and returns it to the client side code (javascript), where it is used to make calls to elevation and other data services from Esri.
98
+
```shell
99
+
gulp watch
100
+
```
61
101
62
-
On the front-end:
102
+
This does a bunch of things:
63
103
64
-
* Bootstrap and jQuery provides the stack for the mobile-adaptive layout
65
-
* Leaflet is used for the map
66
-
* Esri-Leaflet helps utilize Esri services in conjunction with the Leaflet map
104
+
* it compiles and bundles `js` files from the `src` and `node_modules` directory, and puts them in the the `app/static` directory (where the application wants them to be)
105
+
* it does the same with `css` files
106
+
* it copies assets from certain `js` modules to the `app/static/assets` directory,
107
+
* it fires up the Python-Flask application and its development web server for you (runs `pipenv shell python run.py`)
108
+
* it opens up your default browser and loads the page.
67
109
68
-
Front-end business logic is written in javascript with only jQuery. Javascript bundling for _business-logic only_ is being handled by the Flask plugin Flask-Assets.
110
+
3. Develop and see changes as they happen
69
111
70
-
NOTE: Currently, all javascript (including 3rd party dependencies like Leaflet) are being loaded through standard `<script>` tags in the `html`. In the future 3rd-party dependencies should installed with `npm`, explicitly imported into the business logic scripts, and all should be bundled with a task runner like Gulp, Webpack, or Rollup.
112
+
With #2 complete, when you change code in the `src` folder, the browser will either:
71
113
72
-
### Configuration (`config.py`)
114
+
* live reload (inserting your changes into the page)
115
+
* refresh automatically (if it needs to reload an entire script or asset again)
73
116
74
-
#### ArcGIS Application Registration
117
+
## Build
118
+
119
+
Use `gulp build` from the command line to compile source code and copy assets in the `app` folder. Once built, only the `app` folder (and its contents) and `application.py` script are required for running the web application in production.
120
+
121
+
Make sure your `config.py``DEBUG` parameter is set to `False` for production!
75
122
76
-
_to be completed_
123
+
## Deployment
77
124
78
-
* Application ID
79
-
* Application Secret
125
+
There are many ways to deploy this application. Some options:
80
126
81
-
### Deployment
127
+
### PythonAnywhere
82
128
83
-
There are many ways to deploy this application. [PythonAnywhere](https://www.pythonanywhere.com/) provides a great place for deploying Flask applications like this. This one could also easily be deployed to AWS Elastic Beanstalk.
129
+
[PythonAnywhere](https://www.pythonanywhere.com/) provides a great place for deploying a Flask applications like this. Follow [this](https://help.pythonanywhere.com/pages/Flask/) guide for deployment.
84
130
85
-
####Deployment to AWS Elastic Beanstalk
131
+
### Deployment to AWS Elastic Beanstalk
86
132
87
-
Follow [this](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html) guide for deployment.
133
+
Follow [this](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html) guide for deployment to AWS EBS.
88
134
89
135
As of this writing, AWS Elastic Beanstalk supports Python 3.4.
0 commit comments