Permet de donner un conseil chaque jour.. Pour améliorer notre quotidien, Ou pas.
Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
|
- import requests
- from config import advice_api
- import os
-
- def fetch_advice():
- print("Getting new advice...")
- request = requests.get(advice_api)
- if str(request) != '<Response [200]>' :
- print("Mauvaise réponse de l'api !(Check_Latest) ")
- return False
- print(u"réponse correcte !")
- advice = request.json()['slip']['advice']
- return advice
-
- def create_file(message):
- with open('cache_advice', "a") as write_file:
- write_file.write('\n')
- write_file.write(message)
-
- def main():
- print("Nothing to do here")
- advice = fetch_advice()
- print(advice)
- create_file(advice)
-
- if __name__ == '__main__':
- main()
|