File size: 1,185 Bytes
4874bc8
 
90397d7
4874bc8
90397d7
 
 
 
 
 
 
 
 
3512ad1
 
 
90397d7
4874bc8
90397d7
4874bc8
06664a3
90397d7
 
4874bc8
90397d7
06664a3
4874bc8
 
06664a3
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
from libretranslate.app import create_app
from libretranslate.default_values import DEFAULT_ARGUMENTS as DEFARGS
from waitress import serve

def create_args():
    """Return default arguments compatible with Hugging Face Spaces."""
    class Args:
        def __init__(self):
            self.host = "0.0.0.0"  # Listen on all interfaces
            self.port = 7860       # Default port for Hugging Face Spaces
            self.debug = False
            self.ssl = False
            self.url_prefix = ""
            self.load_only = DEFARGS['LOAD_ONLY'] # Initialize with default value
            self.update_models = DEFARGS.get('UPDATE_MODELS', False)  # Initialize with default value
            self.force_update_models = DEFARGS.get('FORCE_UPDATE_MODELS', False)# Initialize with default value
            # Set any other defaults you need

    return Args()

def main(environ, start_response):
    """Main entry point for the application."""
    args = create_args()
    app = create_app(args)
    print(f"Running on http://{args.host}:{args.port}{args.url_prefix}")
    return app(environ, start_response)

if __name__ == "__main__":
    serve(main, host="0.0.0.0", port=7860)