bugfix
This commit is contained in:
parent
8d1bafcd6a
commit
0b68a3d06b
@ -80,6 +80,7 @@ class BaseProcessor:
|
|||||||
self.run_ns['ref_real_path'] = self.real_path
|
self.run_ns['ref_real_path'] = self.real_path
|
||||||
self.run_ns['processor'] = self
|
self.run_ns['processor'] = self
|
||||||
self.env_set = True
|
self.env_set = True
|
||||||
|
request['run_ns'] = self.run_ns
|
||||||
|
|
||||||
async def execute(self,request):
|
async def execute(self,request):
|
||||||
await self.set_run_env(request)
|
await self.set_run_env(request)
|
||||||
|
|||||||
@ -7,6 +7,22 @@ from urllib.parse import quote
|
|||||||
import json
|
import json
|
||||||
import asyncio
|
import asyncio
|
||||||
from aiohttp import BasicAuth
|
from aiohttp import BasicAuth
|
||||||
|
from aiohttp.web import (
|
||||||
|
HTTPException,
|
||||||
|
HTTPBadRequest,
|
||||||
|
HTTPUnauthorized,
|
||||||
|
HTTPForbidden,
|
||||||
|
HTTPNotFound,
|
||||||
|
HTTPMethodNotAllowed,
|
||||||
|
HTTPRequestTimeout,
|
||||||
|
HTTPConflict,
|
||||||
|
HTTPGone,
|
||||||
|
HTTPUnsupportedMediaType,
|
||||||
|
HTTPTooManyRequests,
|
||||||
|
HTTPInternalServerError,
|
||||||
|
HTTPBadGateway,
|
||||||
|
HTTPServiceUnavailable
|
||||||
|
)
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
@ -46,6 +62,25 @@ from .filedownload import path_download, file_download
|
|||||||
from .filestorage import FileStorage
|
from .filestorage import FileStorage
|
||||||
from .serverenv import ServerEnv
|
from .serverenv import ServerEnv
|
||||||
|
|
||||||
|
def server_error(errcode):
|
||||||
|
exceptions = {
|
||||||
|
400: HTTPBadRequest,
|
||||||
|
401: HTTPUnauthorized,
|
||||||
|
403: HTTPForbidden,
|
||||||
|
404: HTTPNotFound,
|
||||||
|
405: HTTPMethodNotAllowed,
|
||||||
|
408: HTTPRequestTimeout,
|
||||||
|
409: HTTPConflict,
|
||||||
|
410: HTTPGone,
|
||||||
|
415: HTTPUnsupportedMediaType,
|
||||||
|
429: HTTPTooManyRequests,
|
||||||
|
500: HTTPInternalServerError,
|
||||||
|
502: HTTPBadGateway,
|
||||||
|
503: HTTPServiceUnavailable
|
||||||
|
}
|
||||||
|
E = exceptions.get(errcode, HTTPException)
|
||||||
|
raise E()
|
||||||
|
|
||||||
def basic_auth_headers(user, passwd):
|
def basic_auth_headers(user, passwd):
|
||||||
ba = BasicAuth(login=user, password=passwd)
|
ba = BasicAuth(login=user, password=passwd)
|
||||||
return {
|
return {
|
||||||
@ -275,6 +310,7 @@ def initEnv():
|
|||||||
g.path_download = path_download
|
g.path_download = path_download
|
||||||
g.partial = partial
|
g.partial = partial
|
||||||
g.StreamHttpClient = StreamHttpClient
|
g.StreamHttpClient = StreamHttpClient
|
||||||
|
g.server_error = server_error
|
||||||
|
|
||||||
def set_builtins():
|
def set_builtins():
|
||||||
all_builtins = [ i for i in dir(builtins) if not i.startswith('_')]
|
all_builtins = [ i for i in dir(builtins) if not i.startswith('_')]
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# setup.cfg
|
# setup.cfg
|
||||||
[metadata]
|
[metadata]
|
||||||
name = ahserver
|
name = ahserver
|
||||||
version = 1.0.7
|
version = 1.0.8
|
||||||
description = A application server base on aiohttp
|
description = A application server base on aiohttp
|
||||||
author = yu moqing
|
author = yu moqing
|
||||||
author_email = yumoqing@gmail.com
|
author_email = yumoqing@gmail.com
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user