Giter Site home page Giter Site logo

usetheapi / flask_url_discovery Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 2.0 41 KB

Flask extension for discovering urls in a service. Automatically expose urls for a service. Manage urls exposure settings.

License: MIT License

Python 100.00%
flask-extensions url-discovery restful python flask

flask_url_discovery's People

Contributors

usetheapi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flask_url_discovery's Issues

AttributeError: 'Flask' object has no attribute 'ud_links'

Flask-UrlDiscovery-1.1.1 , flask-1.0.2 , Python 3.6.7
I have in __init__.py :

from flask import Flask
from flask_url_discovery import url_discovery
def create_app():
    app = Flask(__name__)
    url_discovery(app)
    app.register_blueprint(...

where I added only 2 lines, to import url_discovery and to use it.
With these two lines I get this trace:

    File "/home/hans/.local/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
    File "/home/hans/.local/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
    File "/home/hans/.local/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
    File "/home/hans/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
    File "/home/hans/.local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
    File "/home/hans/.local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/home/hans/.local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/home/hans/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
    File "/home/hans/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
    File "/home/hans/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
    File "/home/hans/.local/lib/python3.6/site-packages/flask_url_discovery/app_registry.py", line 18, in expose_routes
    links = jsonify(current_app.ud_links)
    File "/home/hans/.local/lib/python3.6/site-packages/werkzeug/local.py", line 348, in __getattr__
    return getattr(self._get_current_object(), name)
    AttributeError: 'Flask' object has no attribute 'ud_links'

Is this a bug in flask_url_discovery ? Something I did wrong ? Any help appreciated.

Flask extension

Following steps required:

  • no need to store app from Flask
  • get rid of class UrlDiscovery (system is stateless in order to provide support for multiple flask application under single python process)
  • move matching endpoint to view function from UrlDiscovery.add_private_link() to url_discovery function to provide stateless extension.

The only time flask_urldiscovery has access to flask app is when url_registry called and on url_discovery call

routes with parameters don't work

url_discovery does not validate routes with params like:

@route("/test/app/<id>", methods=["GET"])
def test_adpp(id):
     return "HELLO"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.