get_flask_blueprint
- get_flask_blueprint(converter: Converter, **kwargs: Any) flask.Blueprint [source]
Get a blueprint for
flask.Flask
.- Parameters:
converter – A converter
kwargs – Keyword arguments passed through to
flask.Blueprint
- Returns:
A blueprint
The following is an end-to-end example of using this function to create a small web resolver application.
# flask_example.py from flask import Flask from curies import Converter, get_flask_blueprint, get_obo_converter # Create a converter converter: Converter = get_obo_converter() # Create a blueprint from the converter blueprint = get_flask_blueprint(converter) # Create the Flask app and mount the router app = Flask(__name__) app.register_blueprint(blueprint) if __name__ == "__main__": app.run()
In the command line, either run your Python file directly, or via with
gunicorn
:$ pip install gunicorn $ gunicorn --bind 0.0.0.0:8764 flask_example:app
Test a request in the Python REPL.
import requests url = requests.get("http://localhost:8764/GO:0032571").url assert url == "http://amigo.geneontology.org/amigo/term/GO:0032571"