Python Flask Send Raw HTTP Header Response

Kalau di PHP, Anda pasti mengenal fungsi

header("Location": "someurl")

Dari web PHP docs, fungsi ini untuk mengirim raw http header. Bagaimana melakukan hal tersebut di python Flask?

from flask import make_response
from app import app

@app.route("/")
def index():
    resp = make_response()
    resp.location = "http://someurl"
    resp.status = "301"
    return resp

Done

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s