-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
40 lines (30 loc) · 971 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask import Flask, render_template, request
from flask_mail import Message, Mail
from chat import get_answer, start
app = Flask(__name__)
app.config['MAIL_SERVER'] = 'smtp.rambler.ru'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = '[email protected]' # адрес электронной почты
app.config['MAIL_PASSWORD'] = 'dFgHjK123' # \ пароль
mail = Mail(app)
with app.app_context():
recipient = "[email protected]"
subject = "hello"
body = "Hello"
lang = "rus"
msg = Message(subject=subject,
recipients=["[email protected]"], )
msg.body = body
# mail.send(msg)
@app.get("/")
def index_get():
return render_template("base.html")
@app.post("/predict")
def predict():
text = request.get_json().get("message")
answer = get_answer(text)
message = {"answer": answer}
return message
start()
app.run(debug=True)