Compare commits
4 Commits
d22cacd172
...
3d95635b8b
| Author | SHA1 | Date |
|---|---|---|
|
|
3d95635b8b | 3 years ago |
|
|
9ee7ac359d | 3 years ago |
|
|
702c83f8dc | 3 years ago |
|
|
2d3288c357 | 3 years ago |
@ -1,12 +0,0 @@ |
|||||||
from flask import Flask |
|
||||||
from flask import render_template |
|
||||||
|
|
||||||
app = Flask(__name__) |
|
||||||
|
|
||||||
@app.route('/') |
|
||||||
def hello_world(): |
|
||||||
return render_template('hello.html') |
|
||||||
|
|
||||||
if __name__ == "__main__": |
|
||||||
app.run(debug=True) |
|
||||||
|
|
||||||
@ -0,0 +1,52 @@ |
|||||||
|
# save this as app.py |
||||||
|
from flask import Flask |
||||||
|
from flask import request |
||||||
|
from werkzeug.utils import secure_filename |
||||||
|
from flask_mail import Mail, Message |
||||||
|
|
||||||
|
app = Flask(__name__) |
||||||
|
app.config['MAIL_SERVER']='smtp-stax.alwaysdata.net' |
||||||
|
app.config['MAIL_PORT'] = 587 |
||||||
|
app.config['MAIL_USERNAME'] = 'backup@pokeranalytics.net' |
||||||
|
app.config['MAIL_PASSWORD'] = 'StaxBackup****' |
||||||
|
app.config['MAIL_USE_TLS'] = True |
||||||
|
|
||||||
|
mail = Mail(app) |
||||||
|
|
||||||
|
# EMAIL_HOST = 'smtp-stax.alwaysdata.net' |
||||||
|
# EMAIL_PORT = 587 |
||||||
|
# EMAIL_HOST_USER = 'backup@pokeranalytics.net' |
||||||
|
# EMAIL_HOST_PASSWORD = 'StaxBackup****' |
||||||
|
# EMAIL_USE_TLS = True |
||||||
|
# DEFAULT_FROM_EMAIL = 'Poker Analytics Backup <backup@pokeranalytics.net>' |
||||||
|
|
||||||
|
|
||||||
|
@app.route('/') |
||||||
|
def index(): |
||||||
|
return 'Yeah! Install looks fine!' |
||||||
|
|
||||||
|
@app.route('/send', methods=['GET', 'POST']) |
||||||
|
def sender(): |
||||||
|
if request.method == 'POST': |
||||||
|
# mail = request.args.get('mail', '') |
||||||
|
recipient = request.form['recipient'] |
||||||
|
file = request.files['file'] |
||||||
|
return send_mail(recipient, file) |
||||||
|
else: |
||||||
|
return show_method_error(request.method) |
||||||
|
|
||||||
|
def send_mail(recipient, file): |
||||||
|
|
||||||
|
msg = Message('Poker Analytics Backup', sender = 'backup@pokeranalytics.net', recipients = [recipient]) |
||||||
|
msg.body = "This is the backup" |
||||||
|
|
||||||
|
filename = secure_filename(file.filename) |
||||||
|
msg.attach(filename, "text/csv", file.read()) |
||||||
|
mail.send(msg) |
||||||
|
|
||||||
|
print(mail) |
||||||
|
|
||||||
|
return f'POST to {recipient}' |
||||||
|
|
||||||
|
def show_method_error(method): |
||||||
|
return f'bad method:{method}' |
||||||
Loading…
Reference in new issue