-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
48 lines (44 loc) · 1.08 KB
/
run.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
44
45
46
47
48
import config
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
app = FastAPI(
title="corn job API",
version="0.0.1",
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
expose_headers=["process_time"],
)
"""
HTTP Method: GET
API 主路徑,取得狀態與資訊。
"""
@app.get(
"/",
responses={
200: {
"content": {
"application/json": {
"example": {
"name": "ASR API",
"message": "server started on 8001 PORT development",
"version": "1.0.0",
}
}
}
}
},
tags=["root"],
)
async def root():
return {
"name": "corn job API",
"message": f"server started on {config.PORT} PORT {config.ENV}",
"version": f"{config.VERSION}",
}
app.mount("/", StaticFiles(directory="static"), name="static")