Exemple #1
0
import os

from dotenv import load_dotenv as ld

ld()


class Config:
    API_KEY = os.environ.get("API_KEY")
Exemple #2
0
from dotenv import load_dotenv as ld
from bs4 import BeautifulSoup as bs
import requests
import os, re, json

#API settings
BASE = os.path.abspath(os.path.dirname(__file__))
ld(os.path.join(BASE,'credentials.env'))
API_KEY = os.getenv('API_KEY')
ID=os.getenv('ID')
#wiki API pre settings
password = os.getenv('password')
username = os.getenv('username')
#weather api key
weather_api_key = os.getenv('weather_api_key')

def weather():
    url = f'http://api.openweathermap.org/data/2.5/weather?appid={weather_api_key}&id=3390760'
    resp = requests.get(url).json()
    if resp['cod'] != '404':
        temp = resp['main']
        tempe = round(float(temp['temp']-273.15),2)
        feels = round(float(temp['feels_like']-273.15),2)
        descr = resp['weather'][0]['description']
    return f"Temperature around {tempe}°C, with {descr}, feels like {feels}"

def getPic(pic:str,name:str=None,num=0):
    pattern = r'(\.[\w]+)' #pattern to take just the extension of the file
    if name == None:
        name = pic
    try: