Skip to content

Commit

Permalink
Initialize neo4j, references #2
Browse files Browse the repository at this point in the history
  • Loading branch information
hammad93 committed Mar 2, 2024
1 parent 23f2484 commit 4828401
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
33 changes: 33 additions & 0 deletions neo4j/app.py
@@ -0,0 +1,33 @@
from flask import Flask, request, Response
import requests
from flask_cors import CORS # Import CORS

app = Flask(__name__)
CORS(app) # Enable CORS on the Flask app
NEO4J_URL = "http://localhost:7474/browser" # Default URL where Neo4j browser is running

@app.route('/', defaults={'path': ''}, methods=["GET", "POST", "PUT", "DELETE", "PATCH"])
@app.route('/<path:path>', methods=["GET", "POST", "PUT", "DELETE", "PATCH"])
def proxy(path):
global NEO4J_URL
if request.method == "GET":
resp = requests.get(f'{NEO4J_URL}/{path}', stream=True)
elif request.method == "POST":
resp = requests.post(f'{NEO4J_URL}/{path}', json=request.json, stream=True)
elif request.method == "PUT":
resp = requests.put(f'{NEO4J_URL}/{path}', json=request.json, stream=True)
elif request.method == "DELETE":
resp = requests.delete(f'{NEO4J_URL}/{path}', stream=True)
elif request.method == "PATCH":
resp = requests.patch(f'{NEO4J_URL}/{path}', json=request.json, stream=True)
else:
return 'Unsupported HTTP method', 405

excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
headers = [(name, value) for (name, value) in resp.raw.headers.items()
if name.lower() not in excluded_headers]
response = Response(resp.content, resp.status_code, headers)
return response

if __name__ == '__main__':
app.run(port=8888, debug=True)
3 changes: 3 additions & 0 deletions neo4j/install.sh
@@ -0,0 +1,3 @@
wget https://neo4j.com/artifact.php?name=neo4j-community-5.17.0-unix.tar.gz
tar -xf artifact.php\?name\=neo4j-community-5.17.0-unix.tar.gz
./neo4j-community-5.17.0/bin/neo4j start
6 changes: 6 additions & 0 deletions neo4j/keys.txt
@@ -0,0 +1,6 @@
# Wait 60 seconds before connecting using these details, or login to https://console.neo4j.io to validate the Aura Instance is available
NEO4J_URI=neo4j+s://a8b1f4fd.databases.neo4j.io
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=43SNNN1z7WxtGO95-8uwA0qSLLRk6AgL52OyrbjFVDg
AURA_INSTANCEID=a8b1f4fd
AURA_INSTANCENAME=Instance01

0 comments on commit 4828401

Please sign in to comment.