Simplificada y mejorada la api :3

This commit is contained in:
2020-11-19 06:14:24 -03:00
parent 20c72e3af0
commit c5ad41a8ee
4 changed files with 149 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
from flask import Flask
from flask import Flask, request
from . import services
app = Flask(__name__)
@@ -6,16 +6,19 @@ app.config.from_object('home.settings')
@app.route('/currency')
def currency():
return services.currency.get(app.config['FOREX_KEY'])
base = request.args.get('base', 'CLP')
return services.currency.rates(base, app.config['FIXER_KEY'])
@app.route('/weather')
def weather():
return services.weather.get('temuco', app.config['OPENWEATHERMAP_KEY'])
city = request.args.get('city', 'temuco')
return services.weather.get(city, app.config['OPENWEATHERMAP_KEY'])
@app.route('/photos')
def photos():
return services.photos.get(app.config['UNSPLASH_KEY'])
page = request.args.get('page', 1)
return services.photos.get(app.config['UNSPLASH_KEY'], page)
@app.route('/')
def hello_world():
return 'Hello, World!'
def hey():
return 'Hey, esta es la api men :c!'