flow / app.py
ruv's picture
Update app.py
8efe877 verified
raw
history blame
894 Bytes
from flask import Flask, jsonify
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/api/data')
def get_data():
data = {
"nodes": [
{"id": "1", "data": {"label": "Node 1"}, "position": {"x": 100, "y": 100}},
{"id": "2", "data": {"label": "Node 2"}, "position": {"x": 300, "y": 200}}
],
"edges": [
{"id": "e1-2", "source": "1", "target": "2"}
]
}
return jsonify(data)
@app.route('/hello')
def hello():
return 'Hello, World!'
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def serve(path):
if path != "" and os.path.exists(app.static_folder + '/' + path):
return send_from_directory(app.static_folder, path)
else:
return send_from_directory(app.static_folder, 'index.html')
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7860)