Sanic服务启动失败

创建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]




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值