Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 用烧瓶盛饲料_Python_Flask_Icalendar - Fatal编程技术网

Python 用烧瓶盛饲料

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

我有一个小烧瓶网站,我想从中提供ical提要。 我已经创建了一个ics文件,该文件会经常更新,但是我不知道如何从网站上提供它。
我已经尝试通过
响应
服务文件
来执行此操作,但它们只是显示文件中的文本。

您需要设置正确的响应标题。在您的情况下,标题类似于以下内容:

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