当前位置:网站首页>Sanic服务启动失败

Sanic服务启动失败

2022-06-24 20:07:00 七分辣度

创建sanic服务启动失败:

#!/usr/bin/env python
# -*- coding: utf-8 -*
''' @Project :Sanic01 @File :main.py @Author :Aron @Date :2022/6/21 14:38 '''
from sanic import Sanic
from sanic.response import json,json_dumps

app = Sanic(name='hello-example') # name必须是字符串开头,只能包含数字字母、_、-

@app.get('/')
async def test(request):
    return json({
    
        'hello':'world'
    })

if __name__ == '__main__':
    app.run(host='0.0.0.0',port=8000)

Sanic启动服务时,终端显示:

"D:\Program File\Python\python.exe" "D:\Program File\PythoProfessional\PyCharm 2021.3\plugins\python\helpers\pycharm\_jb_pytest_runner.py" --target main.py::test
Testing started at 15:04 ...
Launching pytest with arguments main.py::test --no-header --no-summary -q in D:\Project\pythonProject\Sanic01\bin

============================= test session starts =============================
collecting ... collected 1 item

main.py::test SKIPPED (async def function and no async plugin instal...) [100%]
Skipped: async def function and no async plugin installed (see warnings)


======================== 1 skipped, 1 warning in 0.12s ========================

Process finished with exit code 0

由于,接口函数以test*开头,被当成了测试用例,随便改个名字(eg. demo)即可正常启动!

"D:\Program File\Python\python.exe" D:/Project/pythonProject/Sanic01/bin/main.py
[2022-06-21 15:10:46 +0800] [18760] [INFO] Sanic v22.3.2
[2022-06-21 15:10:46 +0800] [18760] [INFO] Goin' Fast @ http://0.0.0.0:8000
[2022-06-21 15:10:46 +0800] [18760] [INFO] mode: production, single worker
[2022-06-21 15:10:46 +0800] [18760] [INFO] server: sanic
[2022-06-21 15:10:46 +0800] [18760] [INFO] python: 3.9.0
[2022-06-21 15:10:46 +0800] [18760] [INFO] platform: Windows-10-10.0.19041-SP0
[2022-06-21 15:10:46 +0800] [18760] [INFO] packages: sanic-routing==22.3.0
[2022-06-21 15:10:46 +0800] [18760] [INFO] Starting worker [18760]




原网站

版权声明
本文为[七分辣度]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_43192617/article/details/125391494