77
88@app .route ("/html1" ) # $routeSetup="/html1"
99def html1 (): # $routeHandler
10- return "<h1>hello</h1>" # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
10+ return "<h1>hello</h1>" # $HttpResponse mimetype=text/html 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 $ mimetype=text/html $ responseBody="<h1>hello</h1>"
19- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
18+ resp = make_response ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
19+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
2020
2121
2222@app .route ("/html3" ) # $routeSetup="/html3"
2323def html3 (): # $routeHandler
24- resp = app .make_response ("<h1>hello</h1>" ) # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
25- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
24+ resp = app .make_response ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
25+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
2626
2727
2828# TODO: Create test-cases for the many ways that `make_response` can be used
@@ -31,38 +31,38 @@ def html3(): # $routeHandler
3131
3232@app .route ("/html4" ) # $routeSetup="/html4"
3333def html4 (): # $routeHandler
34- resp = Response ("<h1>hello</h1>" ) # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
35- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
34+ resp = Response ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
35+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=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>" ) # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
43- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
42+ resp = Flask .response_class ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
43+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=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>" ) # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
51- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
50+ resp = app .response_class ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
51+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
5252
5353
5454@app .route ("/html7" ) # $routeSetup="/html7"
5555def html7 (): # $routeHandler
56- resp = make_response () # $HttpResponse $ mimetype=text/html
57- resp .set_data ("<h1>hello</h1>" ) # $f-: responseBody="<h1>hello</h1>"
58- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
56+ resp = make_response () # $HttpResponse mimetype=text/html
57+ resp .set_data ("<h1>hello</h1>" ) # $ MISSING: responseBody="<h1>hello</h1>"
58+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
5959
6060
6161@app .route ("/jsonify" ) # $routeSetup="/jsonify"
6262def jsonify_route (): # $routeHandler
6363 data = {"foo" : "bar" }
64- resp = jsonify (data ) # $f-: HttpResponse $f-: mimetype=application/json $f-: responseBody=data
65- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
64+ resp = jsonify (data ) # $ MISSING: HttpResponse mimetype=application/json responseBody=data
65+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
6666
6767################################################################################
6868# Tricky return handling
@@ -73,19 +73,19 @@ def tricky_return1(): # $routeHandler
7373 if "raw" in request .args :
7474 resp = "<h1>hellu</h1>"
7575 else :
76- resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
77- return resp # $HttpResponse $ mimetype=text/html $ responseBody=resp
76+ resp = make_response ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
77+ return resp # $HttpResponse mimetype=text/html responseBody=resp
7878
7979def helper ():
8080 if "raw" in request .args :
8181 return "<h1>hellu</h1>"
8282 else :
83- return make_response ("<h1>hello</h1>" ) # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
83+ return make_response ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
8484
8585@app .route ("/tricky-return2" ) # $routeSetup="/tricky-return2"
8686def tricky_return2 (): # $routeHandler
8787 resp = helper ()
88- return resp # $HttpResponse $ mimetype=text/html $ responseBody=resp
88+ return resp # $HttpResponse mimetype=text/html responseBody=resp
8989
9090
9191################################################################################
@@ -95,16 +95,16 @@ def tricky_return2(): # $routeHandler
9595
9696@app .route ("/content-type/response-modification1" ) # $routeSetup="/content-type/response-modification1"
9797def response_modification1 (): # $routeHandler
98- resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
99- resp .content_type = "text/plain" # $f-: HttpResponse $f-: mimetype=text/plain
100- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
98+ resp = make_response ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
99+ resp .content_type = "text/plain" # $ MISSING: HttpResponse mimetype=text/plain
100+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
101101
102102
103103@app .route ("/content-type/response-modification2" ) # $routeSetup="/content-type/response-modification2"
104104def response_modification2 (): # $routeHandler
105- resp = make_response ("<h1>hello</h1>" ) # $HttpResponse $ mimetype=text/html $ responseBody="<h1>hello</h1>"
106- resp .headers ["content-type" ] = "text/plain" # $f-: HttpResponse $f-: mimetype=text/plain
107- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
105+ resp = make_response ("<h1>hello</h1>" ) # $HttpResponse mimetype=text/html responseBody="<h1>hello</h1>"
106+ resp .headers ["content-type" ] = "text/plain" # $ MISSING: HttpResponse mimetype=text/plain
107+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
108108
109109
110110# Exploration of mimetype/content_type/headers arguments to `app.response_class` -- things can get tricky
@@ -113,60 +113,60 @@ def response_modification2(): # $routeHandler
113113
114114@app .route ("/content-type/Response1" ) # $routeSetup="/content-type/Response1"
115115def Response1 (): # $routeHandler
116- resp = Response ("<h1>hello</h1>" , mimetype = "text/plain" ) # $HttpResponse $ mimetype=text/plain $ responseBody="<h1>hello</h1>"
117- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
116+ resp = Response ("<h1>hello</h1>" , mimetype = "text/plain" ) # $HttpResponse mimetype=text/plain responseBody="<h1>hello</h1>"
117+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
118118
119119
120120@app .route ("/content-type/Response2" ) # $routeSetup="/content-type/Response2"
121121def Response2 (): # $routeHandler
122- resp = Response ("<h1>hello</h1>" , content_type = "text/plain; charset=utf-8" ) # $HttpResponse $ mimetype=text/plain $ responseBody="<h1>hello</h1>"
123- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
122+ resp = Response ("<h1>hello</h1>" , content_type = "text/plain; charset=utf-8" ) # $HttpResponse mimetype=text/plain responseBody="<h1>hello</h1>"
123+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
124124
125125
126126@app .route ("/content-type/Response3" ) # $routeSetup="/content-type/Response3"
127127def Response3 (): # $routeHandler
128128 # content_type argument takes priority (and result is text/plain)
129- resp = Response ("<h1>hello</h1>" , content_type = "text/plain; charset=utf-8" , mimetype = "text/html" ) # $HttpResponse $ mimetype=text/plain $ responseBody="<h1>hello</h1>"
130- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
129+ resp = Response ("<h1>hello</h1>" , content_type = "text/plain; charset=utf-8" , mimetype = "text/html" ) # $HttpResponse mimetype=text/plain responseBody="<h1>hello</h1>"
130+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
131131
132132
133133@app .route ("/content-type/Response4" ) # $routeSetup="/content-type/Response4"
134134def Response4 (): # $routeHandler
135135 # note: capitalization of Content-Type does not matter
136- resp = Response ("<h1>hello</h1>" , headers = {"Content-TYPE" : "text/plain" }) # $HttpResponse $f+: mimetype=text/html $f-: mimetype=text/plain $responseBody="<h1>hello</h1>"
137- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
136+ resp = Response ("<h1>hello</h1>" , headers = {"Content-TYPE" : "text/plain" }) # $HttpResponse responseBody="<h1>hello</h1>" SPURIOUS: mimetype=text/html MISSING: mimetype=text/plain
137+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
138138
139139
140140@app .route ("/content-type/Response5" ) # $routeSetup="/content-type/Response5"
141141def Response5 (): # $routeHandler
142142 # content_type argument takes priority (and result is text/plain)
143143 # note: capitalization of Content-Type does not matter
144- resp = Response ("<h1>hello</h1>" , headers = {"Content-TYPE" : "text/html" }, content_type = "text/plain; charset=utf-8" ) # $HttpResponse $ mimetype=text/plain $ responseBody="<h1>hello</h1>"
145- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
144+ resp = Response ("<h1>hello</h1>" , headers = {"Content-TYPE" : "text/html" }, content_type = "text/plain; charset=utf-8" ) # $HttpResponse mimetype=text/plain responseBody="<h1>hello</h1>"
145+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
146146
147147
148148@app .route ("/content-type/Response6" ) # $routeSetup="/content-type/Response6"
149149def Response6 (): # $routeHandler
150150 # mimetype argument takes priority over header (and result is text/plain)
151151 # note: capitalization of Content-Type does not matter
152- resp = Response ("<h1>hello</h1>" , headers = {"Content-TYPE" : "text/html" }, mimetype = "text/plain" ) # $HttpResponse $ mimetype=text/plain $ responseBody="<h1>hello</h1>"
153- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
152+ resp = Response ("<h1>hello</h1>" , headers = {"Content-TYPE" : "text/html" }, mimetype = "text/plain" ) # $HttpResponse mimetype=text/plain responseBody="<h1>hello</h1>"
153+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
154154
155155
156156@app .route ("/content-type/Flask-response-class" ) # $routeSetup="/content-type/Flask-response-class"
157157def Flask_response_class (): # $routeHandler
158158 # note: flask.Flask.response_class is set to `flask.Response` by default.
159159 # it can be overridden, but we don't try to handle that right now.
160- resp = Flask .response_class ("<h1>hello</h1>" , mimetype = "text/plain" ) # $HttpResponse $ mimetype=text/plain $ responseBody="<h1>hello</h1>"
161- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
160+ resp = Flask .response_class ("<h1>hello</h1>" , mimetype = "text/plain" ) # $HttpResponse mimetype=text/plain responseBody="<h1>hello</h1>"
161+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
162162
163163
164164@app .route ("/content-type/app-response-class" ) # $routeSetup="/content-type/app-response-class"
165165def app_response_class (): # $routeHandler
166166 # note: app.response_class (flask.Flask.response_class) is set to `flask.Response` by default.
167167 # it can be overridden, but we don't try to handle that right now.
168- resp = app .response_class ("<h1>hello</h1>" , mimetype = "text/plain" ) # $HttpResponse $ mimetype=text/plain $ responseBody="<h1>hello</h1>"
169- return resp # $f+: HttpResponse $f+: mimetype=text/html $f+: responseBody=resp
168+ resp = app .response_class ("<h1>hello</h1>" , mimetype = "text/plain" ) # $HttpResponse mimetype=text/plain responseBody="<h1>hello</h1>"
169+ return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
170170
171171
172172# TODO: add tests for setting status code
0 commit comments