python - Flask not registering routes -


i have following code doesn't seem registering routes.

#!/usr/bin/python  import os,sys,json flask import flask, url_for  class foo:      server = flask(__name__)     mountpoint = "/api"      def __init__(self,startup="run",config="",mountpoint="/api"):         self.mountpoint = mountpoint         self.startup = startup         self.server = server      @server.route("/test")     def test(self):         return "hello world!"      def getendpoints(self):         server = self.server         server.test_request_context():             print url_for('test')      def start(self,**kwargs):         getattr(self.server,self.startup)(**kwargs)   if __name__ == "__main__":     mon = foo()     mon.getendpoints()     mon.start(host='0.0.0.0',debug=true) 

if don't call "getendpoints" things seem run fine, /test returns 404. when calling "getendpoints" returns build error. i'm guessing it's simple why getting 404 error in flask? or scope related, i'm still relatively new python i'm little lost problem might be.

i ran code on machine , found removing self argument test function caused /test work fine. in experience, arguments view functions values passed in @route decorator.

see flask docs on routing.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

Redirect to a HTTPS version using .htaccess -