-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
43 lines (31 loc) · 911 Bytes
/
manage.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
# AI Generate Server
from app.main import create_app
# # discord
# from midjourney_bot_app.main import midjourney_bot
# Utils
import sys
import uvicorn
from typing import Optional
# config
from dotenv import load_dotenv
load_dotenv(verbose=True)
def run_server(host: Optional[str] = None, port: Optional[int] = None, build:str = "dev") -> None:
host = host or '0.0.0.0'
port = port or 8080
if build == "dev":
app = create_app(port)
else:
app = create_app(port,build=build)
print("host:",host,"port:",port);
uvicorn.run(app, host=host, port=port)
def main():
input_ = sys.argv
prompt = "_".join(input_[1:])
#runserver
if prompt == "runserver": run_server()
#runserver prod
if prompt == "runserver_prod": run_server(build=input_[2])
#other
else: raise Exception('Not Command')
if __name__=="__main__":
main()