Primer commit con datos
This commit is contained in:
4
services/__init__.py
Normal file
4
services/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from . import weather
|
||||
from . import currency
|
||||
from . import photos
|
||||
|
||||
12
services/currency.py
Normal file
12
services/currency.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import requests
|
||||
|
||||
url = "https://v2.api.forex/rates/latest.json"
|
||||
|
||||
def get(key):
|
||||
data = {
|
||||
'key': key,
|
||||
}
|
||||
|
||||
response = requests.get(url, params=data)
|
||||
return response.json()
|
||||
|
||||
12
services/photos.py
Normal file
12
services/photos.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import requests
|
||||
|
||||
url = "https://api.unsplash.com/photos/"
|
||||
|
||||
def get(key):
|
||||
data = {
|
||||
'client_id': key,
|
||||
}
|
||||
|
||||
response = requests.get(url, params=data)
|
||||
return {'result': response.json()}
|
||||
|
||||
13
services/weather.py
Normal file
13
services/weather.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import requests
|
||||
|
||||
url = "https://api.openweathermap.org/data/2.5/weather/"
|
||||
|
||||
def get(city, key):
|
||||
data = {
|
||||
'q': city,
|
||||
'appid': key,
|
||||
'units': 'metric',
|
||||
}
|
||||
response = requests.get(url, params=data)
|
||||
return response.json()
|
||||
|
||||
Reference in New Issue
Block a user