【发布时间】:2015-08-19 14:34:41
【问题描述】:
我需要每天重新加载托管在pythonAnywhere 上的烧瓶应用程序。是否可以使用我已有的代码自动重新加载应用程序?
该应用程序是一个简单的天数计数器:
import datetime
from flask import Flask, render_template
app = Flask(__name__)
wsgi_app = app.wsgi_app
currentDate = datetime.date.today()
userInput = '07/22/2015'
targetdate = datetime.datetime.strptime(userInput, '%m/%d/%Y').date()
calc = targetdate - currentDate
msg=str(calc.days)
@app.route('/', methods=['GET','POST'])
def index():
return render_template('index.html', message=msg)
我已经经历过: This link 到 pythonAnywhere 论坛,但它是一个脚本,我必须部署在我的电脑上而不是应用程序本身上。
问题:如何每天自动重新加载应用程序?有没有办法使用网站上的日程安排功能做同样的事情?
【问题讨论】:
-
Shell 脚本将是最好的选择。您可以编写简单的 .sh 文件,其中包含运行 Flask 应用程序的命令,并且可以进一步包含在 CRON JOB 中。
-
好的,我试试,谢谢。
-
我所做的是创建一个文件 - reload.sh 和 #!/bin/bash 并触摸 /var/www/wsgi.py 行并安排 reload.sh 文件。步骤有什么问题吗?
标签: python flask reload pythonanywhere