I know pyrevit.routes is a work in progress, but is there a quicker (better) way to update routes definition than reloading pyRevit entirely after making changes?
After a few times my computer gets really unhappy with the Revit memory footprint 
I know pyrevit.routes is a work in progress, but is there a quicker (better) way to update routes definition than reloading pyRevit entirely after making changes?
After a few times my computer gets really unhappy with the Revit memory footprint 
I have not looked into memory efficiency of this method, but you can use routes.remove_route(api_name, pattern, method) and then register a new function for your endpoint. It is possible that Python’s garbage collection will take care of the old function.
This is basically what I have gotten working with a button that I can click to start a server without having to put the script in startup.py:
from pyrevit import routes
api = routes.API(api_name)
api_name = 'pyalliant-api'
pattern = '/my_pattern/'
methods = ['GET']
all_routes = routes.get_routes(api_name)
all_patterns = [x[0] for x in all_routes.keys()] # all_routes looks like {Route(pattern='/pattern/', method='GET'): <function>, ...}
# remove old endpoint
if pattern in all_patterns:
for method in methods:
try:
routes.remove_route(api_name, pattern, method)
except Exception as e:
print('Failed to remove endpoint {}: {}'.format(method, e))
# register new endpoint
@api.route(pattern)
def do_something(doc):
routes.make_response(data='Hello from do_something')