Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,36 @@ def decorated_function(*args, **kwargs):
return jsonify(message="Unauthorized"), 401
return f(*args, **kwargs)
return decorated_function


@app.route('/', methods=['GET'])
def index():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how you should generate the list of endpoints:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def home():
    return 'Home Page'

@app.route('/about')
def about():
    return 'About Page'

@app.route('/contact', methods=['GET', 'POST'])
def contact():
    return 'Contact Page'

# Function to list all endpoints
def list_routes(app):
    routes = []
    for rule in app.url_map.iter_rules():
        routes.append({
            "endpoint": rule.endpoint,
            "methods": list(rule.methods),
            "url": rule.rule
        })
    return routes

if __name__ == '__main__':
    # Print all routes before running the app
    for route in list_routes(app):
        print(f"Endpoint: {route['endpoint']}, Methods: {route['methods']}, URL: {route['url']}")
    
    app.run(debug=True)

"""
Return a list of all the available routes as HTML response with clickable links.
"""

return """
<!DOCTYPE html>
<html>
<head>
<title>Falkor Code-Graph-Backend API</title>
<link rel="icon" href="https://code-graph.falkordb.com/favicon.ico" type="image/x-icon"/>
</head>
<body>
<h1>Welcome to the Falkor Code-Graph-Backend API</h1>
<h2>Available Routes:</h2>
<ul>
<li><a href="/graph_entities?repo=repo_name">/graph_entities?repo=repo_name</a></li>
<li><a href="/get_neighbors?repo=repo_name&node_id=1">/get_neighbors?repo=repo_name&node_id=1</a></li>
<li><a href="/auto_complete">/auto_complete</a></li>
<li><a href="/list_repos">/list_repos</a></li>
<li><a href="/repo_info">/repo_info</a></li>
<li><a href="/find_paths">/find_paths</a></li>
<li><a href="/chat">/chat</a></li>
</ul>
</body>
"""

@app.route('/graph_entities', methods=['GET'])
@token_required # Apply token authentication decorator
def graph_entities():
Expand Down
Loading