-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
44 lines (35 loc) · 1.25 KB
/
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
36
37
38
39
40
41
42
43
44
import os
# Import Flask
from flask import Flask, send_from_directory
from flask_restful import Api
from flask_cors import CORS
# Import DB
from backend.database.db import initialize_db
from backend.resources.routes import initialize_routes
# Initialization
app = Flask(__name__, static_folder="ui/build")
api = Api(app, catch_all_404s=True)
# cors = CORS(app, resources=r"/*")
cors = CORS(app, resources={r"/*": {"origins": "*"}})
# Config
app.config["MONGODB_SETTINGS"] = {
# "host": "mongodb+srv://CS6620-Team:W5N3ifJvglp1Y9SZ@cluster0.ytua9.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
"host":
"mongodb+srv://CS6620-Team:W5N3ifJvglp1Y9SZ@cluster0.ytua9.mongodb.net/bucicd_test_db?retryWrites=true&w=majority"
}
initialize_db(app)
initialize_routes(api)
# Serve UI static files
@app.route("/", defaults={"path": ""})
@app.route("/<path:path>")
def serve(path):
if path == "":
return send_from_directory("UI/build", "index.html")
else:
if os.path.exists("UI/build/" + path):
return send_from_directory("UI/build", path)
else:
return send_from_directory("UI/build", "index.html")
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0", port=5000)
# app.run(debug=True, port=5000)