我如何更改spyne中的django应用程序服务器端口号
我正在尝试在计算机上运行Spyne Django Soap Server项目,但是我无法运行该项目,因为默认的端口号为8000,已经在使用,因此我想更改Django Soap Server的端口号。
相关代码:
class Attributes(DjangoComplexModel.Attributes):
django_model = FieldContainer
django_exclude = ['excluded_field']
class HelloWorldService(Service):
@rpc(Unicode, Integer, _returns=Iterable(Unicode))
def say_hello(ctx, name, times):
for i in range(times):
yield 'Hello, %s' % name
class ContainerService(Service):
@rpc(Integer, _returns=Container)
def get_container(ctx, pk):
try:
return FieldContainer.objects.get(pk=pk)
except FieldContainer.DoesNotExist:
raise ResourceNotFoundError('Container')
@rpc(Container, _returns=Container)
def create_container(ctx, container):
try:
return FieldContainer.objects.create(**container.as_dict())
except IntegrityError:
raise ResourceAlreadyExistsError('Container')
class ExceptionHandlingService(DjangoService):
"""Service for testing exception handling."""
@rpc(_returns=Container)
def raise_does_not_exist(ctx):
return FieldContainer.objects.get(pk=-1)
@rpc(_returns=Container)
def raise_validation_error(ctx):
raise ValidationError(None, 'Invalid.')
app = Application([HelloWorldService, ContainerService,
ExceptionHandlingService],
'spyne.examples.django',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11(),
)
hello_world_service = csrf_exempt(DjangoApplication(app))
I am trying to run the spyne Django soap server project on my computer but I can't run the project because the default port number which is 8000, is already in use so I want to change the port number of django soap server.
the related code:
class Attributes(DjangoComplexModel.Attributes):
django_model = FieldContainer
django_exclude = ['excluded_field']
class HelloWorldService(Service):
@rpc(Unicode, Integer, _returns=Iterable(Unicode))
def say_hello(ctx, name, times):
for i in range(times):
yield 'Hello, %s' % name
class ContainerService(Service):
@rpc(Integer, _returns=Container)
def get_container(ctx, pk):
try:
return FieldContainer.objects.get(pk=pk)
except FieldContainer.DoesNotExist:
raise ResourceNotFoundError('Container')
@rpc(Container, _returns=Container)
def create_container(ctx, container):
try:
return FieldContainer.objects.create(**container.as_dict())
except IntegrityError:
raise ResourceAlreadyExistsError('Container')
class ExceptionHandlingService(DjangoService):
"""Service for testing exception handling."""
@rpc(_returns=Container)
def raise_does_not_exist(ctx):
return FieldContainer.objects.get(pk=-1)
@rpc(_returns=Container)
def raise_validation_error(ctx):
raise ValidationError(None, 'Invalid.')
app = Application([HelloWorldService, ContainerService,
ExceptionHandlingService],
'spyne.examples.django',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11(),
)
hello_world_service = csrf_exempt(DjangoApplication(app))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法只有在“ RunServer”命令之后输入所需的端口SO:
The easiest way out there is just type the required port to run after the "runserver" command so:
运行Django应用程序时,指定端口
python manage.py runserver 0.0.0.0:8080
用于使用8080而不是8000When you run the django app specify the port like this
python manage.py runserver 0.0.0.0:8080
to use 8080 instead of 8000