def index(): now = datetime.now() special_day = random() predictions = generate_prophecies() + generate_prophecies() return { 'date': f'{now.day}-0{now.month}-{now.year}', 'predictions': predictions, 'special_date': special_day > 0.5, 'special_day': special_day, }
def index(): now = dt.now() prophecies = generate_prophecies() return { "date": f"{now.year}-{now.day}-{now.month}", "prophecies": prophecies }
def send_text(message): if message.text.lower() == 'привет': hello_answer = get_hello_answer() bot.send_message(message.chat.id, random.choice(hello_answer)) elif message.text.lower() == 'пока': bye_answer = get_bye_answer() bot.send_message(message.chat.id, random.choice(bye_answer)) elif message.text.lower() == 'я тебя люблю': love_answer = get_love_answer() bot.send_message(message.chat.id, random.choice(love_answer)) elif message.text.lower() == 'как дела?' or message.text.lower( ) == 'как дела': how_are_you_answer = get_how_are_you_answer() bot.send_message(message.chat.id, random.choice(how_are_you_answer)) elif message.text.lower() == 'хорошо' or message.text.lower() == 'отлично': good_answer = get_good_answer() bot.send_message(message.chat.id, random.choice(good_answer)) elif message.text.lower() == 'что делаешь?' or message.text.lower( ) == 'что делаешь': what_are_you_doing_answer = get_what_are_you_doing_answer() bot.send_message(message.chat.id, random.choice(what_are_you_doing_answer)) elif message.text.lower() == 'ты тупой' or message.text.lower( ) == 'ты глупый': bad_words_answer = get_bad_words_answer() bot.send_message(message.chat.id, random.choice(bad_words_answer)) elif message.text.lower() == 'гороскоп': prophecies = generate_prophecies() bot.send_message(message.chat.id, prophecies) else: do_not_understand_words = get_answer_do_not_understand() bot.send_message(message.chat.id, random.choice(do_not_understand_words))
def main(): today = dt.now().date() save_page( title='Гороскоп на сегодня', header='Что день ' + str(today) + ' готовит', paragraphs=generate_prophecies(total_num=3, num_sentences=4), footer=generate_footer('about.html', 'О реализации'), )
def index(): now = dt.now() x = random() return { "date": f"{now.year}-{now.month}-{now.day}", "prophecies": generate_prophecies(), }
def index(): now = dt.now() x = random() return { "date": f"{now.day}.{now.month}.{now.year}", "predictions": generate_prophecies(), "special_date": x > 0.5, "x": x, }
def index(): now = dt.now() x = random() predicions = generate_prophecies() return { "date": f"{now.year} - {now.month} - {now.day}", "predicions": predicions, "spetial_date": x > 0.5, "x": x }
def index(): now = dt.now() return { "special_date": False, "predictions": generate_prophecies(), "date": f"{now.year}-{now.month}-{now.day}", # "predictions": [ # ["Раз", "Два", "Три"] # ] }
def index(): now = dt.now() x = random() return { "date": f"{now.year}-{now.month}-{now.day}", "predictions": horoscope.generate_prophecies(5, 3), "special_date": x > 0.5, "x": x, }
def index(): now = dt.now() x = random() predictions = generate_prophecies() # Получаю рандомный список предсказаний return { "date": f"{now.day}-{now.month}-{now.year}", "predictions": predictions, "special_date": x > 0.5, "x": x }
def generate_something(): now = dt.now() x = random() response.headers["Access-Control-Allow-Origin"] = "*" return { "date": f"{now.year}-{now.month}-{now.day}", "predictions": generate_prophecies(), "special_date": x > 0.5, "x": x }
def save_page(): prophecies = generate_prophecies() today = dt.now().date() body = generate_body(header="Гороскоп на " + str(today), paragraphs=prophecies) head = generate_head(title="Гороскоп") page = head + body fp = open("in.html", "w") print(page, file=fp) fp.close()
def index(): now = dt.now() x = random() return { "date": f"{now.year}-{now.month}-{now.day}", "predictions": generate_prophecies(total_num=6, num_sentences=2), "special_date": x > 0.5, "x": x, }
def save_page(): p = generate_prophecies() today = dt.now().date() head = generate_head(title='Гороскоп') body = generate_body(header="Гороскоп на " + str(today), paragraphs=p) link = generate_link(text_link='О реализации') page = head + body + link index_open = open("index.html", "w") print(page, file=index_open) index_open.close()
def make_prediction(): from horoscope import generate_prophecies fp = generate_prophecies(3,4) i = 0 prediction = "" while i < len(fp): a = fp[i] prediction = prediction + " <p> " + str(a) + " </p> " i +=1 prediction = prediction + " <hr> " + '<p> <a href = "/about.html"> О реализации </a>' return (prediction)
def index(): now = dt.now() x = random() special_date = x > 0.5 return { "date": f"{now.year}-{now.month}-{now.day}", "predictions": generate_prophecies(6, 2), #[ # "После обеда ожидайте неожиданного праздника.", # "Днем остерегайтесь неожиданного праздника.", # "Утром ожидайте гостей из забытого прошлого.", # ], "special_date": x > 0.5, "x": x, }
def api_test(): return {"prophecies": generate_prophecies()}
page = f'<!DOCTYPE html><html lang="en">{head}{body}</html>' try: with codecs.open(data['file_name_html'], 'w', 'utf-8') as fp: fp.write(page) is_ok = True except: is_ok = False return is_ok data_index_html = { 'file_name_html': 'index.html', 'title': 'Main page horoscope', 'name_article': 'Что день ' + str(dt.now().date()) + ' готовит', 'text_article': generate_prophecies(), 'link': 'about.html', 'a_text': 'About project', } data_about_html = { 'file_name_html': 'about.html', 'title': 'About page horoscope', 'name_article': 'Описание проекта', 'text_article': [ 'Эта страница о проекте обучения по курсу школы ' 'SkillFactory - изучение Python - генерация Горскопа' ],
return page def generate_head(title): head='<meta charset = "utf-8">'+'<title>'+title+'</title>' return '<head>'+head+'</head>' def generate_body(header, paragraphs,link,link_name): body='<h1>'+header+'</h1>' for p in paragraphs: body +='<p>'+p+'</p>' body +='<p>'+add_link(link,link_name)+'</p>' return '<body>'+body+'</body>' def save_page(title,header,paragraphs,link,link_name,output='index.html'): fp=open(output,'w',encoding='utf-8') page=generate_page(head=generate_head(title),body=generate_body(header,paragraphs,link,link_name)) print(page,file=fp) fp.close() def add_link(link,link_name): link=f'<a href="{link}">{link_name}</a>' return link today = dt.now().date() link_a='about.html' name = 'О реализации' save_page("Гороскоп на сегодня ",header=" Что день "+str(today)+' готовит ',paragraphs=generate_prophecies(),link=link_a, link_name=name)
def api_test(): prophecies = generate_prophecies(6, 2) return {"prophecies": prophecies}
def api_new (): return {"prophises" : horoscope.generate_prophecies()}
def api_forecasts(): predictions = generate_prophecies(total_num=6, num_sentences=2) return { "predictions": predictions, }
def api_forecasts(): pr = generate_prophecies(1, 1) return {"prophecies": pr}
def cast_forecasts(): " Возвращаем 6 строчек с предсказаниями " return {"prophecies": generate_prophecies(total_num=6, num_sentences=2)}
def index(): return {"predictions": generate_prophecies(total_num=6, num_sentences=2)}
return a def save_page(title, header, paragraphs, link, link_title, output="index.html"): fp = open(output, "w") today = dt.now().date() page = generate_page(head=generate_head(title), body=generate_body(header=header, paragraphs=paragraphs), a=generate_hyperlink(link=link, title=link_title)) print(page, file=fp) fp.close() title = "Гороскоп" header = "Ваши предсказания на " + dt.now().strftime("%Y-%m-%d") link = "https://developerrr.github.io/horoscope/about.html" link_title = "О реализации" save_page( title, header, generate_prophecies(3, 4), link, link_title, )
""" return head def generate_body(header, paragraphs): body = f"<h1>{header}</h1>" for p in paragraphs: body = body + f"<p>{p}</p>" return f"<body>{body}</body>" def save_page(title, header, paragraphs, output="index.html"): fp = open(output, "w") today = dt.now().date() page = generate_page(head=generate_head(title), body=generate_body(header=header, paragraphs=paragraphs)) print(page, file=fp) fp.close() ##################### today = dt.now().date() save_page( title="Гороскоп на сегодня", header="Что день " + str(today) + " готовит", paragraphs=generate_prophecies(), )
def api_forecasts(): return { 'predictions': generate_prophecies(), }
def api_forecast(): return {"prophecies" : generate_prophecies(6,2)}
def index(): now = dt.now() return {"date": f'{now.year}-{now.month}-{now.day}', "predictions": generate_prophecies()}