-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (25 loc) · 985 Bytes
/
Copy pathapp.py
File metadata and controls
33 lines (25 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Blueprint, render_template, request
import requests
app = Blueprint('app', __name__)
API_URL = 'http://127.0.0.1:5000/emprendimientos'
@app.route("/")
def index():
return render_template('index.html')
@app.route("/emprendimientos/<categoria>")
def emprendimientos(categoria):
try:
response = requests.get(API_URL)
response.raise_for_status()
emprendimientos = response.json().get('emprendimientos', [])
except requests.exceptions.RequestException as e:
print(f"Error fetching data: {e}")
emprendimientos = []
if categoria != 'busqueda':
emprendimientos = [e for e in emprendimientos if categoria.lower() in e['categoria'].lower()]
return render_template('emprendimientos.html', categoria=categoria, emprendimientos=emprendimientos)
@app.route("/login")
def login():
return render_template('login.html')
@app.route("/contacto")
def contacto():
return render_template('contacto.html')