diff --git a/app.py b/app.py new file mode 100644 index 0000000..b340380 --- /dev/null +++ b/app.py @@ -0,0 +1,24 @@ +from flask import Flask, request,url_for,render_template,abort +from lxml import etree +import os +app = Flask(__name__) + +@app.route('/',methods=["GET","POST"]) +def inicio(): + doc=etree.parse("sevilla.xml") + municipios=doc.findall("municipio") + return render_template("inicio.html",municipios=municipios) + +@app.route('/') +def temperatura(code): + try: + doc=etree.parse("http://www.aemet.es/xml/municipios/localidad_"+code+".xml") + except: + abort(404) + name=doc.find("nombre").text + max=doc.find("prediccion/dia/temperatura").find("maxima").text + min=doc.find("prediccion/dia/temperatura").find("minima").text + return render_template("temperaturas.html",name=name,max=max,min=min) + +if __name__ == '__main__': + app.run() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8a4a6b4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +click==6.7 +Flask==0.12.2 +itsdangerous==0.24 +Jinja2==2.9.6 +lxml==4.0.0 +MarkupSafe==1.0 +Werkzeug==0.12.2 diff --git a/sevilla.xml b/sevilla.xml new file mode 100644 index 0000000..030aab6 --- /dev/null +++ b/sevilla.xml @@ -0,0 +1,106 @@ + + Alanís + Albaida del Aljarafe + Alcalá de Guadaíra + Alcalá del Río + Alcolea del Río + Algaba, La + Algámitas + Almadén de la Plata + Almensilla + Arahal + Aznalcázar + Aznalcóllar + Badolatosa + Benacazón + Bollullos de la Mitación + Bormujos + Brenes + Burguillos + Cabezas de San Juan, Las + Camas + Campana, La + Cantillana + Cañada Rosal + Carmona + Carrión de los Céspedes + Casariche + Castilblanco de los Arroyos + Castilleja de Guzmán + Castilleja de la Cuesta + Castilleja del Campo + Castillo de las Guardas, El + Cazalla de la Sierra + Constantina + Coria del Río + Coripe + Coronil, El + Corrales, Los + Cuervo de Sevilla, El + Dos Hermanas + Écija + Espartinas + Estepa + Fuentes de Andalucía + Garrobo, El + Gelves + Gerena + Gilena + Gines + Guadalcanal + Guillena + Herrera + Huévar del Aljarafe + Isla Mayor + Lantejuela, La + Lebrija + Lora de Estepa + Lora del Río + Luisiana, La + Madroño, El + Mairena del Alcor + Mairena del Aljarafe + Marchena + Marinaleda + Martín de la Jara + Molares, Los + Montellano + Morón de la Frontera + Navas de la Concepción, Las + Olivares + Osuna + Palacios y Villafranca, Los + Palomares del Río + Paradas + Pedrera + Pedroso, El + Peñaflor + Pilas + Pruna + Puebla de Cazalla, La + Puebla de los Infantes, La + Puebla del Río, La + Real de la Jara, El + Rinconada, La + Roda de Andalucía, La + Ronquillo, El + Rubio, El + Salteras + San Juan de Aznalfarache + Sanlúcar la Mayor + San Nicolás del Puerto + Santiponce + Saucejo, El + Sevilla + Tocina + Tomares + Umbrete + Utrera + Valencina de la Concepción + Villamanrique de la Condesa + Villanueva del Ariscal + Villanueva del Río y Minas + Villanueva de San Juan + Villaverde del Río + Viso del Alcor, El + \ No newline at end of file diff --git a/static/css/arrow.png b/static/css/arrow.png new file mode 100644 index 0000000..6decd73 Binary files /dev/null and b/static/css/arrow.png differ diff --git a/static/css/arrow_select.png b/static/css/arrow_select.png new file mode 100644 index 0000000..1d4d119 Binary files /dev/null and b/static/css/arrow_select.png differ diff --git a/static/css/back.png b/static/css/back.png new file mode 100644 index 0000000..4e0acbe Binary files /dev/null and b/static/css/back.png differ diff --git a/static/css/panel.png b/static/css/panel.png new file mode 100644 index 0000000..b5d484d Binary files /dev/null and b/static/css/panel.png differ diff --git a/static/css/pattern.png b/static/css/pattern.png new file mode 100644 index 0000000..fa3c2f6 Binary files /dev/null and b/static/css/pattern.png differ diff --git a/static/css/style.css b/static/css/style.css new file mode 100644 index 0000000..ce8b701 --- /dev/null +++ b/static/css/style.css @@ -0,0 +1,277 @@ +* +{ margin: 0; + padding: 0;} + +body +{ font-family: 'trebuchet ms', arial, sans-serif; + padding: 0px; + margin: 0px; + font-size: .80em; + background: #E9E4C7 url(pattern.png); + color: #555;} + +p +{ margin: 0px; + padding: 0px 0px 16px 0px; + line-height: 1.7em;} + +h1, h2, h3, h4, h5, h6 +{ color: #362C20; + padding: 0 0 5px 0;} + +h1, h4 +{ font: normal 175% "century gothic", arial; + margin: 0 0 15px 0; + padding: 15px 20px 5px 0; + color: #444;} + +h2, h5 +{ padding: 0 0 5px 0; + font: normal 110% arial; + text-transform: uppercase; + letter-spacing: 0;} + +h3, h6 +{ color: #888; + font: normal 95% arial; + letter-spacing: 0; + padding: 0 0 15px 0;} + +h4 +{ color: #362C20;} + +h5, h6 +{ color: #129991;} + +img +{ border: 0px; + margin: 0px; + padding: 0px;} + +.left +{ float: left; + border-right: 20px solid #FFF;} + +.right +{ float: right; + border-left: 20px solid #FFF;} + +.center +{ display: block; + text-align: center; + margin: 0 auto;} + +blockquote +{ margin: 20px 0px 20px 0px; + padding: 10px 20px 0px 20px; + border: 1px solid #E5E5DB; + background: #F5F5F1;} + +ul +{ margin: 2px 0px 18px 16px; + padding: 0px;} + +ul li +{ list-style-type: square; + margin: 0px 0px 6px 0px; + padding: 0px;} + +ol +{ margin: 8px 0px 0px 24px; + padding: 0px;} + +ol li +{ margin: 0px 0px 11px 0px; + padding: 0px;} + +a, a:hover +{ outline: none; + border-bottom: 1px dotted; + text-decoration: none; + color: #444;} + +a:hover +{ border-bottom: 1px solid;} + +#logo, #menubar, #panel, #site_content, #footer +{ margin-left: auto; + margin-right: auto;} + +#header +{ background: url(back.png) repeat-x;} + +#logo +{ width: 870px; + position: relative; + height: 107px;} + +#logo #logo_text +{ position: absolute; + top: 15px; + left: 0;} + +#logo h1 +{ font: normal 300% "century gothic", arial, sans-serif; + border-bottom: 0; + text-transform: none; + padding: 12px 0 0 26px; + color: #FFF; + margin: 0;} + +#menubar +{ width: 879px; + height: 45px; + padding-left: 5px;} + +ul#menu{float: right;margin: 0px;} + +ul#menu li +{ float: left; + margin: 7px 0 0 0; + padding: 0 0 0 6px; + list-style: none;} + +ul#menu li a +{ font-size: 110%; + display: block; + float: left; + height: 25px; + border-bottom: 0; + text-decoration: none; + padding: 8px 32px 5px 26px; + text-align: center; + color: #FFF; + text-transform: uppercase;} + +ul#menu li.tab_selected a +{ height: 25px; + padding: 8px 32px 5px 26px;} + +ul#menu li.tab_selected +{ margin: 7px 0 0 0; + background: transparent url(tabs.png) no-repeat 0 0px;} + +ul#menu li.tab_selected a, ul#menu li.tab_selected a:hover +{ background: url(tabs.png) no-repeat 100% 0px; + color: #000;} + +ul#menu li a:hover +{ color: #27C0FF;} + +#panel +{ width: 792px; + height: 154px; + border: 15px solid #F3F2EF;} + +#site_content +{ width: 875px; + background: #FFF; + overflow: hidden; padding-top: 20px;} + +.sidebar +{ float: right; + width: 178px; + padding: 20px 25px 15px 15px;} + +.sidebar ul +{ width: 178px; + padding-top: 4px; + margin: 4px 0px 30px 0px;} + +.sidebar li +{ list-style: none; + padding: 0px 0px 4px 0px;} + +.sidebar li a, .sidebar li a:hover +{ text-decoration: none; + padding: 0px 0px 0px 18px; + display: block; + background: transparent url(arrow.png) no-repeat left center; + color: #555; + border: none;} + +.sidebar li a.selected, .sidebar li a:hover, .sidebar li a.selected:hover +{ background: transparent url(arrow_select.png) no-repeat left center;} + +#content +{ text-align: left; + width: 597px; + padding: 20px 10px 15px 26px;} + +#footer +{ width: 780px; + height: 33px; + padding: 20px 20px 4px 20px; + margin-bottom: 20px; + text-align: center; + background: transparent; + color: #444; + text-transform: uppercase;} + +.alternate_colour +{ color: #27C0FF;} + +.form_settings +{ margin: 15px 0 0 0;} + +.form_settings p +{ padding: 0 0 4px 0;} + +.form_settings span +{ float: left; + width: 200px; + text-align: left;} + +.form_settings input, .form_settings textarea +{ padding: 4px; + width: 299px; + font: 100% arial; + border: 1px solid #E5E5DB; + background: #FFF; + color: #47433F;} + +.form_settings .submit +{ font: 100% arial; + border: 1px solid; + width: 99px; + margin: 0 0 0 210px; + height: 36px; + padding: 2px 0 3px 0; + cursor: pointer; + background: #3B3B3B; + color: #FFF;} + +.form_settings textarea, .form_settings select +{ font: 100% arial; + width: 299px;} + +.form_settings select +{ width: 304px;} + +.form_settings .checkbox +{ margin: 4px 0; + padding: 0; + width: 14px; + border: 0; + background: none;} + +.separator +{ width: 100%; + height: 0; + border-top: 1px solid #D9D5CF; + border-bottom: 1px solid #FFF; + margin: 0 0 20px 0;} + +table +{ margin: 10px 0 30px 0;} + +table tr th, table tr td +{ text-align: left; + background: #3B3B3B; + color: #FFF; + padding: 7px 4px;} + +table tr td +{ background: #CCCCCC; + color: #47433F; + border-top: 1px solid #FFF;} \ No newline at end of file diff --git a/static/css/tabs.png b/static/css/tabs.png new file mode 100644 index 0000000..201070c Binary files /dev/null and b/static/css/tabs.png differ diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..bf67d9f --- /dev/null +++ b/templates/base.html @@ -0,0 +1,45 @@ + + + + + {% block title %}{% endblock %} + + + + + +
+ +
+
tree tops
+ +
+ {% block content %}{% endblock %} +
+
+ +
+
Diseño descargado desde plantillas web gratis.
+ \ No newline at end of file diff --git a/templates/inicio.html b/templates/inicio.html new file mode 100644 index 0000000..ecf8d62 --- /dev/null +++ b/templates/inicio.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% block title %}Temperaturas{% endblock %} +{% block content %} + +{% endblock %} \ No newline at end of file diff --git a/templates/resultado.html b/templates/resultado.html new file mode 100644 index 0000000..f9538b5 --- /dev/null +++ b/templates/resultado.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} +{% block title %}{{titulo}}{% endblock %} +{% block content %} +

{{resultado}}

+{% endblock %} \ No newline at end of file diff --git a/templates/temperaturas.html b/templates/temperaturas.html new file mode 100644 index 0000000..1aaec66 --- /dev/null +++ b/templates/temperaturas.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} +{% block title %}Temperaturas{% endblock %} +{% block content %} +

Temperaturas en {{name}}

+

Temperatura máxima:{{max}}ºC

+

temperatura mínima:{{min}}ºC

+ Volver +{% endblock %} \ No newline at end of file