-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
58 lines (47 loc) · 1.66 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from flask import Flask
from flask_session import Session
from flask_cors import CORS
from apis import api
from models import db
import config as app_config
import os
import logging
app = Flask(__name__)
app.config['SECRET_KEY']=app_config.config.SECRET_KEY
app.config['SESSION_PERMANENT'] = True
app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///:memory:'
UPLOAD_FOLDER = 'uploads/'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
# if app_config.config.ENV == 'development':
# app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///:memory:'
# else:
# path = app_config.config.CHROMA_SERVER_PATH
# os.makedirs(os.path.dirname(path), exist_ok=True)
# # f = open(os.path.join(app_config.config.CHROMA_SERVER_PATH, "app.db"), 'w')
# app.config['SQLALCHEMY_DATABASE_URI']="sqlite:///" +os.path.join(app_config.config.CHROMA_SERVER_PATH, "app.db") # chroma.sqlite3
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config.update(SESSION_COOKIE_SAMESITE="None", SESSION_COOKIE_SECURE=True)
sess = Session()
api.init_app(app)
sess.init_app(app)
db.init_app(app)
app.app_context().push()
# with app.app_context():
db.create_all()
CORS(app)
logging.info(f'****** APP Enviroment={app_config.config.ENV} *******')
@app.route('/')
def index():
return 'received!', 200
@app.route('/health')
def health():
return "I'm healthy", 200
if __name__ == '__main__':
# from waitress import serve
# serve(app, host="0.0.0.0", port=8080) # listen='0.0.0.0:8081') # port=8080, host="0.0.0.0",
if app_config.config.ENV != 'development':
from waitress import serve
serve(app, host="0.0.0.0", port=8080)
else:
app.run(debug=True)
# python main.py