Submitted originally by: josh.mineroff
Is it possible in domino to have multiple endpoints and we can call any of it from outside? I tried Domino APP with simple hello world using python flask and it worked fine with hello world as output.
My other endpoint is,
http://<url>/hello - but this doesn't work.
My code is simple, as below:
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" @app.route("/hello") def hello2(): return "Hello World2" if __name__ == '__main__': app.run(port=8888, host='0.0.0.0', debug=True)
Comments
2 comments
If you wish to achieve the same functionality in R, please follow the below steps:
1. Create a file named
multiplemodelroutes.R
in your project. Add the below code to this file:2. From your project panel,
a. Click Publish > Model APIs > New Model.
b. Provide a meaningful model name and click next.
c. In the model setup page, specify
multiplemodelroutes.R
as the file name, andmy_model
as the function to be invoked. Click Create Model.3. Once your model builds and launches successfully, navigate to Overview > Tester. Now you can invoke
add_numbers
orsay_hello
function by passing the appropriate function name and parameters. For example:a. If you want to call
add_numbers
, enter this and click Sendb. If you want to call
say_hello
, enter this and click SendSubmitted by: akshay.ambekar
Thanks for the wonderful question! You can use Model APIs in Domino to publish multiple REST APIs. Models APIs are better than Apps in the sense that the exposed endpoints that can be autoscaled by Domino to provide programmatic access to code.
To achieve this, please follow the below steps to test it:
1. Create a file named
multiplemodelroutes.py
in your project. Add the below code to this file:2. a. Click Publish > Model APIs > New Model.
b. Provide a meaningful model name and click next.
c. In the model setup page, add
multiplemodelroutes.py
as the file name, andmy_model
as the function to invoke. Click Create Model.3. Once your model builds and launches successfully, navigate to Overview > Tester. Now you can invoke
random_number
orsay_hello
function by passing the appropriate function name and parameters. For example:a. If you want to call
random_number
, enter this and click Sendb. If you want to call
say_hello
, enter this and click SendThis way, by passing the function name and arguments, we can achieve the multiple routing functionality using a Model API. You can get more information about models in Domino here: https://support.dominodatalab.com/hc/en-us/articles/115001488023
Submitted by: akshay.ambekar
Please sign in to leave a comment.