Skip to content

Commit

Permalink
[fix] host
Browse files Browse the repository at this point in the history
  • Loading branch information
WindLX committed Dec 10, 2023
1 parent 1ce04c8 commit 0a3a66c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
4 changes: 3 additions & 1 deletion data/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[system]
host = "127.0.0.1"
port = 13956
port = 13955
backend_host = "127.0.0.1"
backend_port = 13956

[basic]
title = "Pap"
Expand Down
6 changes: 2 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
<body>
<div id="app"></div>
<script>
//window.host = "{{ host }}"
//window.port = "{{ port }}"
window.host = "127.0.0.1"
window.port = 13956
window.host = "{{ host }}"
window.port = "{{ port }}"
</script>
<script type="module" src="/src/main.ts"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pap",
"private": true,
"version": "0.1.9",
"version": "0.2.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
5 changes: 4 additions & 1 deletion src-python/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# system init
host = system_config.host
port = system_config.port
backend_host = system_config.backend_host
backend_port = system_config.backend_port

# database ORM init
Base.metadata.create_all(bind=engine)
Expand All @@ -29,6 +31,7 @@
origins = [
f"http://{dev_config.dev_host}:{dev_config.dev_port}",
f"http://{host}:{port}",
'http://127.0.0.1:13956'
"http://localhost:6174",
]

Expand Down Expand Up @@ -95,4 +98,4 @@ def start_backend(is_dev: bool):
"""Start backend service
"""
logger.info("start backend")
run(app='backend:app', host=host, port=port, reload=is_dev)
run(app='backend:app', host=backend_host, port=backend_port, reload=is_dev)
32 changes: 30 additions & 2 deletions src-python/service/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(self, config_manager: ConfigManager) -> None:

@property
def host(self) -> str:
"""frontend 监听的 host 地址
"""服务运行的 host 地址
Returns:
str: 主机地址
Expand All @@ -154,7 +154,7 @@ def host(self, value: str) -> None:

@property
def port(self) -> int:
"""frontend 监听的 port 端口
"""服务运行的 port 端口
Returns:
int: 端口
Expand All @@ -165,7 +165,35 @@ def port(self) -> int:
def port(self, value: int) -> None:
self.set_property("port", value)

@property
def backend_host(self) -> str:
"""frontend 监听的 host 地址
Returns:
str: 主机地址
"""
return self.get_property("backend_host")

@backend_host.setter
def backend_host(self, value: str) -> None:
self.set_property("backend_host", value)

@property
def backend_port(self) -> int:
"""frontend 监听的 port 端口
Returns:
int: 端口
"""
return self.get_property("backend_port")

@backend_port.setter
def backend_port(self, value: int) -> None:
self.set_property("backend_port", value)

def _create_schema_instance(self, data_dict) -> SystemConfigSchema:
data_dict.pop("host")
data_dict.pop("port")
return SystemConfigSchema(**data_dict)


Expand Down

0 comments on commit 0a3a66c

Please sign in to comment.