GetArticle API to local Neo4J database

This commit is contained in:
2025-03-01 10:32:08 +01:00
parent ae4f4e125e
commit 75564e57a3
4 changed files with 40 additions and 0 deletions

3
.idea/misc.xml generated
View File

@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (Neo4JAPIs)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (Neo4JAPIs)" project-jdk-type="Python SDK" />
</project>

21
APICall/GetArticle.py Normal file
View File

@@ -0,0 +1,21 @@
from flask import Flask, jsonify
from neo4j import GraphDatabase
class Neo4JAPis:
def __init__(self, uri, username, password):
self.app = Flask(__name__)
self.setup_routes()
self.driver = GraphDatabase.driver(uri, auth=(username, password))
def setup_routes(self):
@self.app.route('/article', methods=['GET'])
def get_article():
with self.driver.session() as session:
result = session.run("MATCH (a:Artikel) RETURN a.name AS name, a.EANGTIN as EANGTIN")
article = [{"name": record["name"], "EANGTIN": record["EANGTIN"]} for record in result]
return jsonify(article)
def run(self, debug=True):
self.app.run(debug=debug)

13
main.py Normal file
View File

@@ -0,0 +1,13 @@
import APICall.GetArticle as neo4japi
from flask import Flask
def main():
uri = "bolt://localhost:7687"
username = "neo4j"
password = "daywalker14"
api = neo4japi.Neo4JAPis(uri, username, password)
api.run()
if __name__ == "__main__":
main()

3
requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
Flask
neo4j
pandas