Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Web服务器_Python_Google App Engine_Apple Push Notifications - Fatal编程技术网

Python Web服务器

Python Web服务器,python,google-app-engine,apple-push-notifications,Python,Google App Engine,Apple Push Notifications,我想要一个用于以下用例的简单python web服务器: 我想编写一个简单的服务器,它将接受来自运行在Google App Engine上的应用程序的HTTP请求。 服务器将接受HTTP请求,然后发送iphone通知。(基本上,我需要这个额外的服务器来解释google app engine中缺少套接字支持的原因) 我想我需要服务器能够保持与苹果推送通知服务的持久连接。因此,我需要有一些线程始终为此打开。因此,我需要某种能够接受请求的web服务器,将请求传递给另一个线程,并与APNS保持持久连接

我想要一个用于以下用例的简单python web服务器: 我想编写一个简单的服务器,它将接受来自运行在Google App Engine上的应用程序的HTTP请求。 服务器将接受HTTP请求,然后发送iphone通知。(基本上,我需要这个额外的服务器来解释google app engine中缺少套接字支持的原因)

我想我需要服务器能够保持与苹果推送通知服务的持久连接。因此,我需要有一些线程始终为此打开。因此,我需要某种能够接受请求的web服务器,将请求传递给另一个线程,并与APNS保持持久连接

也许有多个进程和一个python队列工具在它们之间进行通信?接受HTTP请求,然后将消息排入另一个进程的队列


我想知道有点经验的人会有什么建议。我开始认为,甚至编写自己的简单服务器也是一个不错的选择(http://fragments.turtlemeat.com/pythonwebserver.php)一个选项是(适当命名),它是Python标准库的一部分。另一个更灵活但更复杂的选项是将服务器写入。

我一直在使用gevent和瓶子编写简单的http服务器,例如:

#!/usr/bin/env python

import gevent.monkey
gevent.monkey.patch_all()

import bottle
bottle.debug(True)

import gevent.wsgi

from bottle import route, run, request, response, static_file, abort

@route('/echo')
def echo():
    s = request.GET.get('s', 'o hai')
    return '<html><head><title>echo server</title></head><body>%s</body></html>\r\n' % (s)

@route('/static/:filename')
def send_static(filename):
    root = os.getcwd() + '/static'
    return static_file(filename, root=root)

if __name__ == '__main__':
    app = bottle.app()
    wsgi_server = gevent.wsgi.WSGIServer(('0.0.0.0', 8000), app)
    print 'Starting wsgi search on port 8000'
    wsgi_server.serve_forever()
#/usr/bin/env python
导入gevent.monkey
gevent.monkey.patch_all()
进口瓶
beggle.debug(True)
导入gevent.wsgi
从瓶子导入路径,运行,请求,响应,静态文件,中止
@路由(“/echo”)
def echo():
s=request.GET.GET('s','o hai')
返回“回显服务器%s\r\n%”(s)
@路由('/static/:filename')
def send_静态(文件名):
root=os.getcwd()+'/static'
返回静态文件(文件名,root=root)
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
app=瓶子。app()
wsgi_server=gevent.wsgi.WSGIServer(('0.0.0.0',8000),应用程序)
打印“在端口8000上启动wsgi搜索”
wsgi_server.serve_ever()
因此,您可以编写一个简单的服务器,将作业粘贴到队列中(请参见gevent.Queue),并让另一个worker greenlet处理从队列读取的请求并处理它们…

允许您做您想做的事情,并且每月可以免费推送10万次。你也可以密切关注