-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
53 lines (41 loc) · 1.8 KB
/
Copy pathserver.py
File metadata and controls
53 lines (41 loc) · 1.8 KB
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
"""
本地知识库 Web 服务器 — FastAPI + uvicorn
启动: python server.py
"""
import sys
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from core.routes import register_routes
from core.server_utils import startup_diagnostics
app = FastAPI(title="问渠 (Wenqu)", version="0.1.0")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
register_routes(app)
def main():
port = 8080
print()
print(" ██╗ ██╗███████╗███╗ ██╗ ██████╗ ██╗ ██╗")
print(" ██║ ██║██╔════╝████╗ ██║ ██╔═══██╗██║ ██║")
print(" ██║ █╗ ██║█████╗ ██╔██╗ ██║ ██║ ██║██║ ██║")
print(" ██║███╗██║██╔══╝ ██║╚██╗██║ ██║▄▄ ██║██║ ██║")
print(" ╚███╔███╔╝███████╗██║ ╚████║ ╚██████╔╝╚██████╔╝")
print(" ╚══╝╚══╝ ╚══════╝╚═╝ ╚═══╝ ╚══▀▀═╝ ╚═════╝ ")
print(" 本地知识库 RAG 系统 · 问渠那得清如许")
print()
if not startup_diagnostics(port):
try:
input("\n按 Enter 退出...")
except (EOFError, OSError):
pass
sys.exit(1)
import uvicorn
print(f"\n 服务已启动: http://localhost:{port}")
print(" 按 Ctrl+C 停止\n")
uvicorn.run(app, host="0.0.0.0", port=port, log_level="warning")
if __name__ == "__main__":
main()