I keep getting Error: Nonetype
from a Sanic app and I cannot identify the reason.
My code:
from sanic import Sanic
from sanic.response import json, text
from sanic.request import RequestParameters
from parse_data import ParseData
pdata = ParseData()
app = Sanic('sanic_sms')
app = Sanic(__name__)
@app.route("/", methods=["POST",])
async def test(request):
data = {}
if request.form:
data = request.form
elif request.json:
data = request.json
result = pdata.prepare_output(data.get('text'))
resp = json(result)
resp.headers["Access-Control-Allow-Origin"] = "*"
resp.headers["Access-Control-Allow-Headers"] = "Content-Type,Authorization"
return resp
app.run(host="0.0.0.0", port=8002)
2017-05-13 15:10:03,454: INFO: Goin' Fast @ http://0.0.0.0:8002
2017-05-13 15:10:03,456: INFO: Starting worker [30662] 2017-05-13
15:11:19,579: ERROR: NoneType
How can I solve this?
It was probably some bug in some previous version of Sanic (I got that behavior on version 0.4.0).
The app threw NoneType 408
at a constant rate.
Solved it by tempering the KEEP_ALIVE
setting of the Config
dictionary:
from sanic.config import Config
Config.KEEP_ALIVE = False
app = Sanic(__name__)
In the current version (0.7.0) this seems to have been fixed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.