-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (27 loc) · 864 Bytes
/
app.py
File metadata and controls
34 lines (27 loc) · 864 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
34
from flask import Flask, request, render_template
# Creating a flask instancy named app
app = Flask(__name__)
# Main app route
@app.route ('/')
def home():
return render_template('home.html')
# About us
@app.route ('/about')
def about():
return render_template('about.html')
# Contact
@app.route ('/contact')
def contact():
return render_template('contact.html')
# Greetings with name using query string
@app.route('/hello')
def greetings():
name = request.args.get('name') # Get name parameter from the URL
return render_template('hello.html', name=name)
# Product by ID using rute parameters
@app.route('/products/<int:product_id>')
def products(product_id): # Get id parameter from the URL
return f"El id del producto que buscas es: {product_id}"
# To run the server
if __name__ == '__main__':
app.run(debug=True)