-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
35 lines (25 loc) · 821 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from flask import Flask, render_template, jsonify
import os
from graphql_api import handle_graphql_request
from flask_cors import CORS
from dotenv import load_dotenv
from add_papers import add_papers
load_dotenv()
app = Flask(__name__)
CORS(app) # Enable CORS for all routes
@app.route('/health', methods=['GET'])
def health():
return jsonify({"status": "up"}), 200
@app.route('/')
def home():
api_url = os.getenv("API_URL", "http://127.0.0.1:5001/graphql")
return render_template('index.html', api_url=api_url)
# Add the GraphQL endpoint
@app.route('/graphql', methods=['POST'])
def graphql():
return handle_graphql_request()
if __name__ == "__main__":
debug = os.getenv("DEBUG")
port = os.getenv("HTTP_PORT")
# add_papers()
app.run(debug=debug, port=port, use_reloader=False)