master
Laurent Morvillier 3 years ago
parent 99b9a97542
commit d22cacd172
  1. 50
      __init__.py
  2. 12
      __init__.py.old
  3. 52
      app.py

@ -1,12 +1,52 @@
# save this as app.py
from flask import Flask
from flask import render_template
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 hello_world():
return render_template('hello.html')
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)
if __name__ == "__main__":
app.run(debug=True)
return f'POST to {recipient}'
def show_method_error(method):
return f'bad method:{method}'

@ -0,0 +1,12 @@
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)

@ -1,52 +0,0 @@
# 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…
Cancel
Save