From 346ec598af73d622f6a45e054a71ead7286eabd4 Mon Sep 17 00:00:00 2001 From: Cinabre Date: Sat, 9 May 2020 22:23:44 +0200 Subject: [PATCH] Upload files to '' --- advice.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 advice.py diff --git a/advice.py b/advice.py new file mode 100644 index 0000000..babbf36 --- /dev/null +++ b/advice.py @@ -0,0 +1,27 @@ +import requests +from config import advice_api +import os + +def fetch_advice(): + print("Getting new advice...") + request = requests.get(advice_api) + if str(request) != '' : + 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() \ No newline at end of file