77
88@app .route ("/html1" ) # $routeSetup="/html1"
99def html1 (): # $routeHandler
10- return "<h1>hello</h1>" # $f-:HttpResponse $f-:contentType=text/html $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
10+ return "<h1>hello</h1>" # $f-:HttpResponse $f-:contentType=text/html $f-:responseBody="<h1>hello</h1>"
1111
1212
1313@app .route ("/html2" ) # $routeSetup="/html2"
1414def html2 (): # $routeHandler
1515 # note that response saved in a variable intentionally -- we wan the annotations to
1616 # show that we recognize the response creation, and not the return (hopefully). (and
1717 # do the same in the following of the file)
18- resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $contentType=text/html $statusCode=200 $ responseBody="<h1>hello</h1>"
18+ resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $contentType=text/html $responseBody="<h1>hello</h1>"
1919 return resp
2020
2121
2222@app .route ("/html3" ) # $routeSetup="/html3"
2323def html3 (): # $routeHandler
24- resp = app .make_response ("<h1>hello</h1>" ) # $HttpResponse $contentType=text/html $statusCode=200 $ responseBody="<h1>hello</h1>"
24+ resp = app .make_response ("<h1>hello</h1>" ) # $HttpResponse $contentType=text/html $responseBody="<h1>hello</h1>"
2525 return resp
2626
2727
@@ -31,30 +31,30 @@ def html3(): # $routeHandler
3131
3232@app .route ("/html4" ) # $routeSetup="/html4"
3333def html4 (): # $routeHandler
34- resp = Response ("<h1>hello</h1>" ) # $f-:HttpResponse $f-:contentType=text/html $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
34+ resp = Response ("<h1>hello</h1>" ) # $f-:HttpResponse $f-:contentType=text/html $f-:responseBody="<h1>hello</h1>"
3535 return resp
3636
3737
3838@app .route ("/html5" ) # $routeSetup="/html5"
3939def html5 (): # $routeHandler
4040 # note: flask.Flask.response_class is set to `flask.Response` by default.
4141 # it can be overridden, but we don't try to handle that right now.
42- resp = Flask .response_class ("<h1>hello</h1>" ) # $f-:HttpResponse $f-:contentType=text/html $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
42+ resp = Flask .response_class ("<h1>hello</h1>" ) # $f-:HttpResponse $f-:contentType=text/html $f-:responseBody="<h1>hello</h1>"
4343 return resp
4444
4545
4646@app .route ("/html6" ) # $routeSetup="/html6"
4747def html6 (): # $routeHandler
4848 # note: app.response_class (flask.Flask.response_class) is set to `flask.Response` by default.
4949 # it can be overridden, but we don't try to handle that right now.
50- resp = app .response_class ("<h1>hello</h1>" ) # $f-:HttpResponse $f-:contentType=text/html $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
50+ resp = app .response_class ("<h1>hello</h1>" ) # $f-:HttpResponse $f-:contentType=text/html $f-:responseBody="<h1>hello</h1>"
5151 return resp
5252
5353
5454@app .route ("/jsonify" ) # $routeSetup="/jsonify"
5555def jsonify_route (): # $routeHandler
5656 data = {"foo" : "bar" }
57- response = jsonify (data ) # $f-:HttpResponse $f-:contentType=application/json $f-:statusCode=200 $f-: responseBody=data
57+ response = jsonify (data ) # $f-:HttpResponse $f-:contentType=application/json $f-:responseBody=data
5858 return response
5959
6060
@@ -65,14 +65,14 @@ def jsonify_route(): # $routeHandler
6565
6666@app .route ("/content-type/response-modification1" ) # $routeSetup="/content-type/response-modification1"
6767def response_modification1 (): # $routeHandler
68- resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $contentType=text/html $statusCode=200 $ responseBody="<h1>hello</h1>"
68+ resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $contentType=text/html $responseBody="<h1>hello</h1>"
6969 resp .content_type = "text/plain" # $f-:HttpResponse $f-:contentType=text/plain
7070 return resp
7171
7272
7373@app .route ("/content-type/response-modification2" ) # $routeSetup="/content-type/response-modification2"
7474def response_modification2 (): # $routeHandler
75- resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $contentType=text/html $statusCode=200 $ responseBody="<h1>hello</h1>"
75+ resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $contentType=text/html $responseBody="<h1>hello</h1>"
7676 resp .headers ["content-type" ] = "text/plain" # $f-:HttpResponse $f-:contentType=text/plain
7777 return resp
7878
@@ -83,13 +83,13 @@ def response_modification2(): # $routeHandler
8383
8484@app .route ("/content-type/Response1" ) # $routeSetup="/content-type/Response1"
8585def Response1 (): # $routeHandler
86- resp = Response ("<h1>hello</h1>" , mimetype = "text/plain" ) # $f-:HttpResponse $f-:contentType=text/plain $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
86+ resp = Response ("<h1>hello</h1>" , mimetype = "text/plain" ) # $f-:HttpResponse $f-:contentType=text/plain $f-:responseBody="<h1>hello</h1>"
8787 return resp
8888
8989
9090@app .route ("/content-type/Response2" ) # $routeSetup="/content-type/Response2"
9191def Response2 (): # $routeHandler
92- resp = Response ("<h1>hello</h1>" , content_type = "text/plain; charset=utf-8" ) # $f-:HttpResponse $f-:contentType=text/plain $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
92+ resp = Response ("<h1>hello</h1>" , content_type = "text/plain; charset=utf-8" ) # $f-:HttpResponse $f-:contentType=text/plain $f-:responseBody="<h1>hello</h1>"
9393 return resp
9494
9595
@@ -98,14 +98,14 @@ def Response3(): # $routeHandler
9898 # content_type argument takes priority (and result is text/plain)
9999 resp = Response (
100100 "<h1>hello</h1>" , content_type = "text/plain; charset=utf-8" , mimetype = "text/html"
101- ) # $f-:HttpResponse $f-:contentType=text/plain $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
101+ ) # $f-:HttpResponse $f-:contentType=text/plain $f-:responseBody="<h1>hello</h1>"
102102 return resp
103103
104104
105105@app .route ("/content-type/Response4" ) # $routeSetup="/content-type/Response4"
106106def Response4 (): # $routeHandler
107107 # note: capitalization of Content-Type does not matter
108- resp = Response ("<h1>hello</h1>" , headers = {"Content-TYPE" : "text/plain" }) # $f-:HttpResponse $f-:contentType=text/plain $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
108+ resp = Response ("<h1>hello</h1>" , headers = {"Content-TYPE" : "text/plain" }) # $f-:HttpResponse $f-:contentType=text/plain $f-:responseBody="<h1>hello</h1>"
109109 return resp
110110
111111
@@ -115,25 +115,26 @@ def Response5(): # $routeHandler
115115 # note: capitalization of Content-Type does not matter
116116 resp = Response (
117117 "<h1>hello</h1>" , headers = {"Content-TYPE" : "text/html" }, content_type = "text/plain; charset=utf-8"
118- ) # $f-:HttpResponse $f-:contentType=text/plain $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
118+ ) # $f-:HttpResponse $f-:contentType=text/plain $f-:responseBody="<h1>hello</h1>"
119119 return resp
120120
121121
122122@app .route ("/content-type/Flask-response-class" ) # $routeSetup="/content-type/Flask-response-class"
123123def Flask_response_class (): # $routeHandler
124124 # note: flask.Flask.response_class is set to `flask.Response` by default.
125125 # it can be overridden, but we don't try to handle that right now.
126- resp = Flask .response_class ("<h1>hello</h1>" , mimetype = "text/plain" ) # $f-:HttpResponse $f-:contentType=text/plain $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
126+ resp = Flask .response_class ("<h1>hello</h1>" , mimetype = "text/plain" ) # $f-:HttpResponse $f-:contentType=text/plain $f-:responseBody="<h1>hello</h1>"
127127 return resp
128128
129129
130130@app .route ("/content-type/app-response-class" ) # $routeSetup="/content-type/app-response-class"
131131def app_response_class (): # $routeHandler
132132 # note: app.response_class (flask.Flask.response_class) is set to `flask.Response` by default.
133133 # it can be overridden, but we don't try to handle that right now.
134- resp = app .response_class ("<h1>hello</h1>" , mimetype = "text/plain" ) # $f-:HttpResponse $f-:contentType=text/plain $f-:statusCode=200 $f-: responseBody="<h1>hello</h1>"
134+ resp = app .response_class ("<h1>hello</h1>" , mimetype = "text/plain" ) # $f-:HttpResponse $f-:contentType=text/plain $f-:responseBody="<h1>hello</h1>"
135135 return resp
136136
137+
137138# TODO: add tests for setting status code
138139# TODO: add test that manually creates a redirect by setting status code and suitable header.
139140
0 commit comments