本文整理汇总了Python中werkzeug.wrappers.Response.headers['content-type']方法的典型用法代码示例。如果您正苦于以下问题:Python Response.headers['content-type']方法的具体用法?Python Response.headers['content-type']怎么用?Python Response.headers['content-type']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.wrappers.Response
的用法示例。
在下文中一共展示了Response.headers['content-type']方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __get_response
# 需要导入模块: from werkzeug.wrappers import Response [as 别名]
# 或者: from werkzeug.wrappers.Response import headers['content-type'] [as 别名]
def __get_response(self, environ, args, kwargs, endpoint):
if endpoint.__name__ == "service_check":
result = endpoint(*args, **kwargs)
response = Response(result['body'])
response.status_code = result['status']
return response
response = {
'server_info': {
'http_headers': dict(EnvironHeaders(environ)),
'response_id': 0,
'arguments': repr(args) if args else repr(kwargs),
'processing_time': 0.0
},
'response': {}
}
start_time = time.time()
# Make the call
result = endpoint(*args, **kwargs)
# Send the API call response
response['response'] = result
response['server_info']['processing_time'] = 1000*(time.time() - start_time)
try:
response = json.dumps(response)
except (TypeError, UnicodeError):
return InternalServerError(description = "Could not encode service response")
response = Response(response)
response.headers['content-type'] = 'application/json'
return response
示例2: alle_helfer_csv
# 需要导入模块: from werkzeug.wrappers import Response [as 别名]
# 或者: from werkzeug.wrappers.Response import headers['content-type'] [as 别名]
def alle_helfer_csv(request, helferid=None):
columns = "username, email, mobile, tshirt_size, pullover_size, want_participant_shirt, signed_hygiene, signed_fire, COUNT(person_schicht.pers_id) as shiftCount, min(schicht.from_day * 24 + schicht.from_hour) / 24 AS firstday, min(schicht.from_day * 24 + schicht.from_hour) % 24 AS firsthour "
persons = db.select("SELECT {} FROM person LEFT OUTER JOIN person_schicht ON person_schicht.pers_id = person.id LEFT OUTER JOIN schicht ON schicht.id = person_schicht.schicht_id GROUP BY person.id ORDER BY LOWER(username)".format(columns))
#No need for a template, as this is technical data
csv = ','.join(map(lambda x: x.split()[-1], columns.split(', ')))+" \r\n"
csv += u"\r\n".join(",".join('"'+unicode(column).replace('"', '""')+'"' for column in person) for person in persons)
response = Response(csv)
response.headers['content-type'] = 'text/csv; charset=utf-8'
return response
示例3: n3
# 需要导入模块: from werkzeug.wrappers import Response [as 别名]
# 或者: from werkzeug.wrappers.Response import headers['content-type'] [as 别名]
def n3():
response = Response(persist('n3'))
response.headers['content-type'] = "text/n3"
return response
示例4: xml
# 需要导入模块: from werkzeug.wrappers import Response [as 别名]
# 或者: from werkzeug.wrappers.Response import headers['content-type'] [as 别名]
def xml():
response = Response(persist())
response.headers['content-type'] = "application/rdf+xml"
return response
示例5: helfer_ical
# 需要导入模块: from werkzeug.wrappers import Response [as 别名]
# 或者: from werkzeug.wrappers.Response import headers['content-type'] [as 别名]
def helfer_ical(request,helferid):
rows = db.select('''SELECT
schicht.id AS id,
schicht.name AS name,
schicht.description AS description,
station.name AS station_name,
schicht.from_day AS from_day,
schicht.from_hour AS from_hour,
schicht.until_day AS until_day,
schicht.until_hour AS until_hour,
GROUP_CONCAT(s2.username, ", ") as mithelfer
FROM
person_schicht
LEFT JOIN
schicht on person_schicht.schicht_id = schicht.id
JOIN
station ON schicht.station_id = station.id
JOIN
person_schicht as ps ON ps.schicht_id = person_schicht.schicht_id
LEFT JOIN
person as s2 ON ps.pers_id = s2.id AND s2.id != ?
WHERE
person_schicht.pers_id=?
GROUP BY
schicht.id
ORDER BY
schicht.from_day ASC, schicht.from_hour ASC''', (helferid,helferid))
cal = Calendar()
cal.add('prodid', '-//fsi//kiftool//DE')
cal.add('version', '2.0')
for termin in rows:
event = Event()
event.add('summary', termin['name'])
event.add('description', termin['description'] + (" " + termin['mithelfer'] if termin['mithelfer'] else ""))
until_hour = termin['until_hour']
until_min = 0
if until_hour == 24:
until_hour = 23
until_min = 59
if termin['from_day'] < 3:
event.add('dtstart', datetime.datetime(2013,10,29+termin['from_day'],termin['from_hour'],0,0,tzinfo=pytz.timezone('Europe/Berlin')))
else:
event.add('dtstart', datetime.datetime(2013,11,termin['from_day']-2,termin['from_hour'],0,0,tzinfo=pytz.timezone('Europe/Berlin')))
if termin['until_day'] < 3:
event.add('dtend', datetime.datetime(2013,10,29+termin['until_day'],until_hour,until_min,0,tzinfo=pytz.timezone('Europe/Berlin')))
else:
event.add('dtend', datetime.datetime(2013,11,termin['until_day']-2,until_hour,until_min,0,tzinfo=pytz.timezone('Europe/Berlin')))
event.add('dtstamp', datetime.datetime(2013,9,4,0,0,0,tzinfo=pytz.timezone('Europe/Berlin')))
event['uid'] = "2013uid"+str(termin['id'])+"@kif.fsi.informatik.uni-erlangen.de"
event.add('priority', 5)
cal.add_component(event)
response = Response(cal.to_ical())
response.headers['content-type'] = 'text/calendar; charset=utf-8'
return response