File size: 873 Bytes
7a064ce
 
fc3bf2a
 
 
7a064ce
 
 
 
fc3bf2a
 
 
7a064ce
fc3bf2a
7a064ce
fc3bf2a
df6d68c
7a064ce
 
 
 
5ca903c
 
7a064ce
fc3bf2a
 
 
d7c5116
fc3bf2a
7a064ce
 
fc3bf2a
 
 
7a064ce
fc3bf2a
 
7a064ce
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
import os

from flask import Flask
from flask_cors import CORS

import infrastructure.database as db
from infrastructure.logger import get_logger, setup_logger
from routes.api import api_bp
from routes.web import web_bp

setup_logger()


def create_app():
    app = Flask(__name__, template_folder="static")
    CORS(app)

    for k, v in {
        "XDG_CACHE_HOME": "/tmp/cache",
        "HF_HOME": "/tmp/huggingface",
        "TRANSFORMERS_CACHE": "/tmp/huggingface/transformers",
    }.items():
        os.environ.setdefault(k, v)
        os.makedirs(os.path.abspath(v), exist_ok=True)

    app.register_blueprint(web_bp)
    app.register_blueprint(api_bp)

    with app.app_context():
        get_logger().info("Initializing Neon database")
        db.init_db()

    return app


if __name__ == "__main__":
    app = create_app()
    app.run(host="0.0.0.0", port=7860)