コード例 #1
0
ファイル: server_div.py プロジェクト: adwiza/fullstack
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,
    }
コード例 #2
0
def index():
    now = dt.now()
    prophecies = generate_prophecies()
    return {
        "date": f"{now.year}-{now.day}-{now.month}",
        "prophecies": prophecies
    }
コード例 #3
0
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))
コード例 #4
0
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', 'О реализации'),
    )
コード例 #5
0
def index():
    now = dt.now()

    x = random()

    return {
        "date": f"{now.year}-{now.month}-{now.day}",
        "prophecies": generate_prophecies(),
    }
コード例 #6
0
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,
		}
コード例 #7
0
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
    }
コード例 #8
0
ファイル: server.py プロジェクト: HappyDaniil/python-m4-hw
def index():
    now = dt.now()

    return {
        "special_date": False,
        "predictions": generate_prophecies(),
        "date": f"{now.year}-{now.month}-{now.day}",
        # "predictions": [
        #  ["Раз", "Два", "Три"]
        # ]
    }
コード例 #9
0
ファイル: server.py プロジェクト: KznRkjp/my_1_heroku
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,
    }
コード例 #10
0
ファイル: server.py プロジェクト: mkdv00/python_projects
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
    }
コード例 #11
0
ファイル: serv.py プロジェクト: YuliyaZhdanova/module_4
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
    }
コード例 #12
0
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()
コード例 #13
0
ファイル: server.py プロジェクト: MaximLyubin/horoscope
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,
    }
コード例 #14
0
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()
コード例 #15
0
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)
コード例 #16
0
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,
    }
コード例 #17
0
ファイル: server_tack.py プロジェクト: Yavorskikha/module_4
def api_test():
    return {"prophecies": generate_prophecies()}
コード例 #18
0
    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 - генерация Горскопа'
    ],
コード例 #19
0
    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)




コード例 #20
0
def api_test():
    prophecies = generate_prophecies(6, 2)

    return {"prophecies": prophecies}
コード例 #21
0
def api_new ():
    return {"prophises" : horoscope.generate_prophecies()}  
コード例 #22
0
ファイル: server.py プロジェクト: mkdv00/python_projects
def api_forecasts():
    predictions = generate_prophecies(total_num=6, num_sentences=2)

    return {
        "predictions": predictions,
    }
コード例 #23
0
ファイル: server.py プロジェクト: vetsizov/BAD_HOROSCOPE
def api_forecasts():
    pr = generate_prophecies(1, 1)
    return {"prophecies": pr}
コード例 #24
0
def cast_forecasts():
    " Возвращаем 6 строчек с предсказаниями  "
    return {"prophecies": generate_prophecies(total_num=6, num_sentences=2)}
コード例 #25
0
ファイル: server.py プロジェクト: mihdevel/horoscope2
def index():
    return {"predictions": generate_prophecies(total_num=6, num_sentences=2)}
コード例 #26
0
    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,
)
コード例 #27
0
ファイル: generate_all.py プロジェクト: Marlin005/py
    """
    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(),
)
コード例 #28
0
ファイル: server_div.py プロジェクト: adwiza/fullstack
def api_forecasts():
    return {
        'predictions': generate_prophecies(),
    }
コード例 #29
0
def api_forecast():
	return {"prophecies" : generate_prophecies(6,2)}
コード例 #30
0
def index():
	now = dt.now()
	return {"date": f'{now.year}-{now.month}-{now.day}',
	        "predictions": generate_prophecies()}