# HG changeset patch # User paulo # Date 1596441722 21600 # Node ID 2b5d93c5628a494f42ff3877c75e02751905f37d # Parent d8239a080f4468a59e090d91b8ff303cca810ead# Parent 17454b47b15fff19de4b143a7fd239945270a24a merge heads diff -r d8239a080f44 -r 2b5d93c5628a myw2/Dockerfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myw2/Dockerfile Mon Aug 03 02:02:02 2020 -0600 @@ -0,0 +1,17 @@ +# Use the official lightweight Python image. +# https://hub.docker.com/_/python +FROM python:3.6-slim + +# Copy local code to the container image. +ENV APP_HOME /app +WORKDIR $APP_HOME +COPY . ./ + +# Install production dependencies. +RUN pip install -r requirements.pip + +# Run the web service on container startup. Here we use the gunicorn +# webserver, with one worker process and 8 threads. +# For environments with multiple CPU cores, increase the number of workers +# to be equal to the cores available. +CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 myw_flask_app:app diff -r d8239a080f44 -r 2b5d93c5628a myw2/myw_flask_app.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myw2/myw_flask_app.py Mon Aug 03 02:02:02 2020 -0600 @@ -0,0 +1,45 @@ +import collections + +import flask +import markupsafe + +from html3.html3 import HTML + + +app = flask.Flask(__name__) + + +REDIRECTS = collections.OrderedDict({ + "desktop": "http://forecast.weather.gov/MapClick.php?lat=37.63048605200049&lon=-122.41107706299971", + "mobile": "http://mobile.weather.gov/index.php?lat=37.61961&lon=-122.36558", + "radar": "https://radar.weather.gov/lite/N0R/MUX_loop.gif", + "hourly": "http://forecast.weather.gov/meteograms/Plotter.php?lat=37.6305&lon=-122.4111&wfo=MTR&zcode=CAZ508&gset=18&gdiff=3&unit=0&tinfo=PY8&ahour=0&pcmd=11011111111110000000000000000000000000000000000000000000000&lg=en&indu=1!1!1!&dd=&bw=&hrspan=48&pqpfhr=6&psnwhr=6", + "goes": "https://www.star.nesdis.noaa.gov/GOES/sector.php?sat=G17§or=psw", +}) + + +@app.route("/") +def index(): + root = HTML("html") + + header = root.head + header.title("myw") + header.link(rel="stylesheet", type="text/css", + href=flask.url_for("static", filename="index.css")) + + body = root.body(klass="body") + + for i in REDIRECTS: + div = body.div() + div.a(i.capitalize(), href=flask.url_for("show_target", target=i)) + + return str(root).encode("utf-8") + + +@app.route("/") +def show_target(target): + safe_target = markupsafe.escape(target) + if safe_target in REDIRECTS: + return flask.redirect(REDIRECTS[safe_target], code=301) + else: + flask.abort(404) diff -r d8239a080f44 -r 2b5d93c5628a myw2/requirements.pip --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myw2/requirements.pip Mon Aug 03 02:02:02 2020 -0600 @@ -0,0 +1,8 @@ +click==7.1.2 +Flask==1.1.2 +gunicorn==20.0.4 +html3==1.18 +itsdangerous==1.1.0 +Jinja2==2.11.2 +MarkupSafe==1.1.1 +Werkzeug==1.0.1 diff -r d8239a080f44 -r 2b5d93c5628a myw2/static/index.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myw2/static/index.css Mon Aug 03 02:02:02 2020 -0600 @@ -0,0 +1,21 @@ +body +{ + background-color: #111; + color: #ccc; +} + +a:link +{ + color: #831; +} + +a:visited +{ + color: gray; +} + +div { + text-align: center; + line-height: 2; + font-size: 500%; +}