Exemplo n.º 1
0
import requests
import re
import random
from jinja2 import Environment, PackageLoader, select_autoescape

data = cgi.FieldStorage()

print("Content-Type: text/html")
print()

mfs = data.getvalue("data")

lines = mfs.split(",")

alerts = Alert("https://api.weather.gov/alerts/active/")
nwsJson = alerts.requestJSON()

myId = []

for line in lines:
    ids = line.strip("[]\"")
    myId.append(ids)

env = Environment(loader=PackageLoader('alert', 'templates'),
                  autoescape=select_autoescape(['html', 'xml']))

template = env.get_template('newAlerts.html')

for feature in nwsJson:
    i = random.randint(1, 1000)
    if feature['properties']['id'] not in myId:
Exemplo n.º 2
0
from jinja2 import Environment, PackageLoader, select_autoescape
from alert import Alert
import cgi
import cgitb
import re
import random

cgitb.enable()

env = Environment(loader=PackageLoader('alert', 'templates'),
                  autoescape=select_autoescape(['html', 'xml']))

alerts = Alert("https://api.weather.gov/alerts/active/")

parJson = alerts.requestJSON()

h1Title = "Watches, warnings, and advisories"

template_header = env.get_template('thon.html')

template_content = env.get_template("newAlerts.html")

template_footer = env.get_template("footer.html")

title = "Thunder Chasers Alerts - Home"

print("Content-Type: text/html")
print()

print(template_header.render(title=title))