2016-09-22 26 views
0

我正在使用Python3.4和Falcon1.0。我想在falcon API中將請求重定向到另一個資源。將請求重定向到不同的資源(Falcon)

例如,我有2個資源:

class Res1(object): 
    def on_get(self, req, resp): 
     print("I'm on resource 1") 
     resp.status = falcon.HTTP_200 

class Res2(object): 
    def on_get(self, req, resp): 
     print("I'm on resource 2") 
     resp.status = falcon.HTTP_200 

和API URL格式是localhost/{id}。如果id是1 else Res2,我想打電話Res1

回答

0
exception falcon.HTTPMovedPermanently(location) 

你可以試試這個或解釋更多

0

你應該最好把你的邏輯在Python功能和呼叫如果基於該功能在任何您的API,可重複使用的,鬆散耦合的方式的其他條件。

相關問題