各位大大,是不是我的服务器需要配置什么端口之类的?搞了两天了,无法搞好!
代码如下:
from flask import Flask
# from run_celery import make_celery
# from celery import platforms
from flask_mail import Mail,Message
app = Flask(__name__)
app.config.update(
# CELERY_BROKER_URL='redis://localhost:6379/0',
# CELERY_RESULT_BACKEND='redis://localhost:6379/1',
DEBUG = True,
MAIL_SERVER='smtp.qq.com',
MAIL_PROT='25',
# MAIL_USE_SSL = True,
MAIL_USE_TLS = True,
MAIL_USERNAME = '111111@qq.com',
MAIL_PASSWORD = 'rkuynjxxxxxpqicfc',
MAIL_DEBUG = True
)
# celery = make_celery(app)
mail = Mail(app)
@app.route('/')
def index():
msg = Message("This is only test Mail",sender='111111@qq.com',recipients=['22222@qq.com'])
msg.body = "This is my first Mail."
mail.send(msg)
print('Mail send OK')
return 'sent'
if __name__ == '__main__':
app.run()
server {
listen 80;
server_name www.demo.com;
access_log /wwwlogs/www.demo.com_nginx.log combined;
index index.html index.htm index.php;
root /wwwroot/www.demo.com;
location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|swf|flv|mp4)$ {
valid_referers none blocked *.demo.com www.demo.com;
if ($invalid_referer) {
return 403;
}
}
location / {
try_files $uri @flask;
}
location @flask {
proxy_set_header X-real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:5000;
}
location ~ .*\.(bmp|swf|flv|mp4)$ {
expires 30d;
access_log off;
}
location ~ /\.ht {
deny all;
}
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.