Skip to content

Commit 27b8f86

Browse files
committed
added basic app cli
1 parent 8f4f8df commit 27b8f86

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

neographviz/app.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
2+
import argparse
23

3-
from flask import Flask
4+
from flask import Flask, request
45

56
from neographviz import Graph, plot
67

@@ -10,20 +11,22 @@
1011
@app.route("/")
1112
def index():
1213
"Main graph page"
13-
out = plot(graph, template_file="vis.html", app=True)
14+
query = request.args.get('query', 'match p= ()--() return p limit 25')
15+
out = plot(graph, query=query, template_file="vis.html", app=True)
1416
return out
1517

1618

1719
if __name__ == "__main__":
18-
options = sys.argv
19-
if len(options)==1:
20-
graph_host, debug = '', True
21-
elif len(options)==2:
22-
graph_host, debug = options[1], True
23-
elif len(options)==3:
24-
_, graph_host, debug = options
25-
graph = Graph(graph_host)
26-
if bool(debug):
20+
parser = argparse.ArgumentParser(description='Launch a graph visalisation app.')
21+
parser.add_argument('--debug', type=bool, default='True',
22+
help='Flag for debugging')
23+
parser.add_argument('--host', default='', type=str,
24+
help='Path to the graph DB, defaults to localhost')
25+
parser.add_argument('--port', default=5000, type=int,
26+
help='POrt on which to serve the app')
27+
options = parser.parse_args()
28+
graph = Graph(options.host)
29+
if options.debug:
2730
app.run(debug=True, port=5000)
2831
else:
2932
import waitress

neographviz/templates/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@
4747
</head>
4848

4949
<body>
50-
5150
{% if app %}
51+
<form target="/" method="GET">
52+
<input type="text" name="query" sie="100">
53+
<input type="submit" name="submit">
54+
</form>
55+
{% endif %}
5256

53-
{% block interaction %}{% endblock %}
5457

55-
{% endif %}
56-
5758
{% block vis %}{% endblock %}
5859
</body>
5960

neographviz/templates/vis.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{% extends "index.html" %}
2+
{% block vis %}
23

4+
{% block interaction %}{% endblock %}
35

4-
{% block vis %}
56
{% if nodes %}
67

78
<div id="main">

neographviz/vis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def vis_network(
147147
physics=physics,
148148
node_size=node_size,
149149
font_size=font_size,
150+
app=app
150151
)
151152

152153

0 commit comments

Comments
 (0)