Python 用烧瓶盛饲料
我有一个小烧瓶网站,我想从中提供ical提要。 我已经创建了一个ics文件,该文件会经常更新,但是我不知道如何从网站上提供它。Python 用烧瓶盛饲料,python,flask,icalendar,Python,Flask,Icalendar,我有一个小烧瓶网站,我想从中提供ical提要。 我已经创建了一个ics文件,该文件会经常更新,但是我不知道如何从网站上提供它。 我已经尝试通过响应和服务文件来执行此操作,但它们只是显示文件中的文本。您需要设置正确的响应标题。在您的情况下,标题类似于以下内容: Content-Disposition: attachment; filename=calender.ics; from flask import make_response app = Flask(__name__) # ...
我已经尝试通过
响应和服务文件来执行此操作,但它们只是显示文件中的文本。您需要设置正确的响应标题。在您的情况下,标题类似于以下内容:
Content-Disposition: attachment; filename=calender.ics;
from flask import make_response
app = Flask(__name__)
# ...
@app.route('/calendar/')
def calendar():
# Get the calendar data
_calendar = make_calendar()
# turn calendar data into a response
response = make_response(_calendar)
response.headers["Content-Disposition"] = "attachment; filename=calendar.ics"
return response
在烧瓶路径中,代码应如下所示:
Content-Disposition: attachment; filename=calender.ics;
from flask import make_response
app = Flask(__name__)
# ...
@app.route('/calendar/')
def calendar():
# Get the calendar data
_calendar = make_calendar()
# turn calendar data into a response
response = make_response(_calendar)
response.headers["Content-Disposition"] = "attachment; filename=calendar.ics"
return response