Skip to content

Commit

Permalink
fixed docker, but templates not showing?
Browse files Browse the repository at this point in the history
  • Loading branch information
silvae86 committed May 26, 2020
1 parent a7a341c commit db36ba9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
2 changes: 1 addition & 1 deletion conf/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ nvm use v10
echo "Starting archgraph server at $ROOT_DIR"
cd "$ROOT_DIR"

python "$ROOT_DIR/src/Routes/routes.py" --neo4j="$NEO4J_CONNECTION_STRING" --mongodb="$MONGODB_CONNECTION_STRING" &
python "$ROOT_DIR/src/Routes/routes.py" --neo4j="$NEO4J_CONNECTION_STRING" --mongodb="$MONGODB_CONNECTION_STRING" --host="$CUSTOM_HOST_FOR_SERVER_BIND" &
SERVER_PID=$!
cd "$ROOT_DIR/frontend" || ( echo "folder missing " && exit 1 )
if [[ "$RUN_IN_PRODUCTION" != "" ]] ; then
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
environment:
- "NEO4J_CONNECTION_STRING=bolt://neo4j:password@neo4j:7687"
- "MONGODB_CONNECTION_STRING=mongodb://root:rootpassword@mongodb:27017"
- "CUSTOM_HOST_FOR_SERVER_BIND=0.0.0.0"
- "RUN_IN_PRODUCTION=1"
ports:
- published: 4200
Expand Down
14 changes: 5 additions & 9 deletions src/Routes/mongo.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import json
from datetime import datetime
from pymongo import MongoClient
import argparse

parser = argparse.ArgumentParser(description="Starts the archgraph server.")
parser.add_argument("--mongodb", nargs="?", help="Address of the mongodb server")
parser.add_argument("--neo4j", nargs="?", help="Address of the neo4j server")
import src.Utils.ArgParser as ArgParser
args = ArgParser.parse()

args = parser.parse_args()
MONGODB_URL = "mongodb://root:rootpassword@localhost:27017"

if args.mongodb is not None:
if args.mongodb is not None and args.mongodb != "":
MONGODB_URL = args.mongodb
else:
MONGODB_URL = "mongodb://root:rootpassword@localhost:27017"

client = MongoClient(MONGODB_URL)
client = MongoClient(host=MONGODB_URL)
db = client.mydatabase
date_now = datetime.now().strftime("%Y-%m-%d, %H:%M:%S")

Expand Down
32 changes: 22 additions & 10 deletions src/Routes/routes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
from pathlib import Path
import os, sys
import argparse


# returns the project root path (assumes that the script is started from src/Routes/routes.py)
Expand All @@ -15,10 +14,6 @@ def get_project_root():
print("Archgraph running at " + get_project_root().as_posix())
sys.path.append(get_project_root().as_posix())

parser = argparse.ArgumentParser(description="Starts the archgraph server.")
parser.add_argument("--neo4j", nargs="?", help="Address of the neo4j server")
parser.add_argument("--mongodb", nargs="?", help="Address of the mongodb server")
args = parser.parse_args()

from flask import Flask, Response, jsonify, make_response, request, send_from_directory

Expand All @@ -28,20 +23,35 @@ def get_project_root():
from src.Utils.JsonEncoder import search_cidoc, search_specific_cidoc
from src.Utils.Utils import get_node_by_uid, build_next_json, updated_node, make_result

if args.neo4j:
import src.Utils.ArgParser as ArgParser
args = ArgParser.parse()

if args.neo4j and args.neo4j != "":
config.DATABASE_URL = args.neo4j
else:
config.DATABASE_URL = "bolt://neo4j:password@localhost:7687"

from src.Routes.mongo import insert_template_in_mongo, get_all_records_from_collection, get_schema_from_mongo, \
get_templates_from_mongo_by_classes_name
from src.Routes.mongo import insert_template_in_mongo, get_all_records_from_collection, get_schema_from_mongo, get_templates_from_mongo_by_classes_name

app = Flask(__name__)

CORS(app)
cors = CORS(app, resources={r"/*": {"origins": "*"}})
app = Flask(__name__, static_url_path="")
app.debug = True

@app.before_request
def log_request_info():
app.logger.debug('Headers: %s', request.headers)
app.logger.debug('Body: %s', request.get_data())

@app.after_request
def after(response):
# todo with response
print(response.status)
print(response.headers)
print(response.get_data())
return response

@app.route("/favicon.ico")
def favicon():
Expand Down Expand Up @@ -234,6 +244,8 @@ def search_specific(class_name, query):
# json = read_file("../Utils/defaultTemplates.json")
# populate_template_collection(json)
# get_all_records_from_collection("createdTemplate")

if __name__ == "__main__":
app.run(host='127.0.0.1')
if args.host is not None and args.host != "":
app.run(host=args.host)
else:
app.run(host='127.0.0.1')
16 changes: 16 additions & 0 deletions src/Utils/ArgParser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import argparse


def parse():
parser = argparse.ArgumentParser(description="Starts the archgraph server.")
parser.add_argument("--mongodb", nargs="?", help="Address of the mongodb server")
parser.add_argument("--neo4j", nargs="?", help="Address of the neo4j server")
parser.add_argument("--host", nargs="?", help="Address of the neo4j server")

args = parser.parse_args()

return args


class ArgParser:
pass

0 comments on commit db36ba9

Please sign in to comment.