├── .gitignore
├── __init__.py
├── requirements.txt
├── .gitattributes
├── LICENSE
├── README.md
├── templates
├── index.html
└── base.html
├── app.py
└── sample-forecast.json
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | venv
3 |
--------------------------------------------------------------------------------
/__init__.py:
--------------------------------------------------------------------------------
1 | from flask import Flask
2 |
3 | app = Flask(__name__)
4 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | requests==2.20.0
2 | Flask==1.0
3 | Flask-Caching==1.3.3
4 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Julian Norton
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Experiment to render the weather forecast as fast as possible. ~~Goal is sub 100ms.~~ ~40 milliseconds if you're in NYC.
2 |
3 | ## Set-up
4 |
5 | ```
6 | python3 -m venv venv && source venv/bin/activate && pip3 install -r requirements.txt && FLASK_APP=app.py FLASK_DEBUG=1 python -m flask run --port=5001
7 | ```
8 |
9 |
10 | #### Good resources
11 | * Setting up Flask: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
12 |
13 |
14 | ### Production setup
15 |
16 | ```
17 | # Use a screen
18 | # [not needed after venv installed] sudo python3 -m venv venv
19 | screen
20 | source venv/bin/activate
21 | sudo -H pip3 install -r requirements.txt
22 | sudo FLASK_APP=app.py python3 -m flask run --port=5001
23 | ```
24 | `Ctrl a` `p` to detatch from the screen
25 |
26 | ### Production reset
27 |
28 | ```
29 | (To find python processes:)
30 | ps -ef | grep python
31 | sudo kill -9 23826
32 | ("23826" is whatever the number is returned that you want to kill)
33 | screen
34 | sudo git pull
35 | sudo python3 -m venv venv
36 | source venv/bin/activate
37 | sudo -H pip3 install -r requirements.txt
38 | sudo FLASK_APP=app.py python3 -m flask run --port=5001
39 | ```
40 |
--------------------------------------------------------------------------------
/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 |