def router(app, sio) -> None:
app.add_route(views.index, "/", methods=["GET"])
app.add_route(views.signup, "/signup", methods=["POST"])
app.add_route(views.signin, "/signin", methods=["POST"])
app.add_route(views.refresh, "/refresh", methods=["POST"])
app.add_route(views.signout, "/signout", methods=["POST"])
app.add_route(views.challenge, "/challenge/<token>", methods=["GET"])
app.static("/assets", pathjoin(".", "client", "assets"))
sio.on("/join_queue", events.join_queue)
python类index()的实例源码
def test_about_from_index(self):
"""Test traveling from index to about page"""
link = 'http://startupfairy.com/'
httpretty.register_uri(httpretty.GET, link)
response = requests.get(link)
self.assertEqual(200, response.status_code)
link = 'http://startupfairy.com/about'
httpretty.register_uri(httpretty.GET, link,
body='[{"title": "About | Startup Fairy"}]',
content_type="application/json")
response = requests.get(link)
self.assertEqual(200, response.status_code)
#self.assertEqual('', httpretty.last_request().body)
def test_index_1(self):
"""Test that index renders properly"""
with app.test_request_context():
self.assertEqual(index() is not None, True)