标签: wsgiserver

尝试运行Django应用程序时出现WSGIServer错误

首先,这是我的脚本:

#!/usr/bin/python
import sys, os

sys.path.append('/home/username/python')
sys.path.append("/home/username/python/flup")
sys.path.append("/home/username/python/django")
# more path stuff

os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
Run Code Online (Sandbox Code Playgroud)

正如所描述这里.

这是我尝试从shell运行它时得到的错误:

WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 404 NOT FOUND
Content-Type: text/html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<!-- more html which looks to be …
Run Code Online (Sandbox Code Playgroud)

django fastcgi wsgiserver

8
推荐指数
1
解决办法
1万
查看次数

Flask,CherryPy和静态内容

我知道有很多关于FlaskCherryPy以及静态文件的问题,但我似乎仍然无法使其工作.

这里有一个片段可以在CherryPy上部署Flask应用程序:http: //flask.pocoo.org/snippets/24/

是否有快速修改让wsgiserver提供烧瓶应用程序的静态目录中的内容?

CherryPy的静态内容功能似乎位于CherryPy中.我不确定如何安装CherryPy应用程序,除了在使用此代码段时提供静态内容之外什么都不做.

deployment cherrypy wsgiserver flask

8
推荐指数
1
解决办法
2031
查看次数

Python:在文件更改时自动重新启动WSGIServer + Bottle应用程序

我正在与Bottle&Gevent玩一个HTTP + WebSockets服务器。如果要在Node中实现此功能,则在开发过程中,我将使用Nodemon或类似方法在更改代码后重新启动服务器。如果我仅使用Bottle和run我相信可以使用的方法,run(reloader=True)但是我正在使用运行应用程序WSGIServer。鉴于此,我该如何获得自动重装功能?

http_server = WSGIServer(('127.0.0.1', 8080), app, handler_class=WebSocketHandler)

python wsgiserver bottle

5
推荐指数
1
解决办法
3201
查看次数

如何以详细或调试模式运行WSGIServer?

我正在使用以下代码片段在python中运行WSGIServer:

from bottle import request, Bottle, abort
app = Bottle()

.. other stuff ... 

from gevent.pywsgi import WSGIServer
from geventwebsocket import WebSocketError
from geventwebsocket.handler import WebSocketHandler
server = WSGIServer(("0.0.0.0", 8080), app,
                    handler_class=WebSocketHandler)
server.serve_forever()
Run Code Online (Sandbox Code Playgroud)

服务器工作正常但每次我向此服务器发送请求时,控制台上都没有打印出来(直接运行服务器时瓶子或瓶子的方式).那些控制台日志真的可以帮助我理解浏览器的要求.我尝试在上面的代码中的几个地方插入debug = True,但似乎都没有.我究竟做错了什么 ?

python wsgiserver bottle

4
推荐指数
1
解决办法
2038
查看次数

带有ssl的Python Gevent Pywsgi服务器

我试图用gevent.pywsgi.WSGIServer包装Flask应用程序。一切正常,但是,当我尝试为ssl添加密钥和证书时,它甚至无法再接受任何客户端。

这是一个引发错误的简单示例:

from gevent.pywsgi import WSGIServer
from flask import Flask

app = Flask(__name__)
app.debug = True

@app.route('/')
def index():
    """
    Renders the homepage.
    """
    return render_template('index.html')

if __name__ == "__main__":
    app.config["SECRET_KEY"] = "ITSASECRET"
    http_server = WSGIServer(('localhost', 5000), app, keyfile='key.pem', 
certfile='cert.pem')
    http_server.serve_forever()
Run Code Online (Sandbox Code Playgroud)

这是错误的堆栈跟踪:

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\gevent\greenlet.py", line 536, in run
    result = self._run(*self.args, **self.kwargs)
  File "C:\Python27\lib\site-packages\gevent\baseserver.py", line 26, in 
_handle_and_close_when_done
    return handle(*args_tuple)
  File "C:\Python27\lib\site-packages\gevent\server.py", line 173, in 
wrap_socket_and_handle
    ssl_socket = self.wrap_socket(client_socket, **self.ssl_args)
  File "C:\Python27\lib\site-packages\gevent\_sslgte279.py", line …
Run Code Online (Sandbox Code Playgroud)

python ssl wsgiserver gevent flask

4
推荐指数
1
解决办法
2277
查看次数

WSGIServer 出现“0.0.0.0”错误 - 需要整数(获取字节类型)

我正在WSGIServer使用地址运行'0.0.0.0'

    from gevent import pywsgi
    from geventwebsocket.handler import WebSocketHandler

    server = pywsgi.WSGIServer(('0.0.0.0', 5002), app, handler_class=WebSocketHandler)

    server.serve_forever()
Run Code Online (Sandbox Code Playgroud)

哪个会产生错误TypeError: an integer is required (got type bytes)

如果我改变'0.0.0.0'一切'127.0.0.1'都很好。

我在 MacOS 10.14.6 上使用 Python 3.8

这是完整的错误

Traceback (most recent call last):   
File "/Users/ronharlev/Documents/MyProject/streaming_server.py", line 174, in run_process
        server.serve_forever()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/baseserver.py", line 367, in serve_forever
        self.start()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/baseserver.py", line 305, in start
        self.init_socket()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/pywsgi.py", line 1491, in init_socket
        self.update_environ()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/pywsgi.py", line 1503, in update_environ
        name …
Run Code Online (Sandbox Code Playgroud)

python wsgiserver python-3.x

4
推荐指数
1
解决办法
979
查看次数

类型错误:需要类似字节的对象,而不是“str”WSGI 服务器

我无法使用 Python 3.5 解决这个问题。此代码对于 3 之前的 Python 来说是可以的。我正在实现 Django 应用程序所需的 WSGI Web 服务器。

文件的名称是:webserver2.py。但他告诉我

TypeError: a bytes-like object is required, not 'str'
Run Code Online (Sandbox Code Playgroud)

你能帮助我吗?

import socket
#import StringIO
import io
import sys


class WSGIServer(object):
    address_family = socket.AF_INET
    socket_type = socket.SOCK_STREAM
    request_queue_size = 1

    def __init__(self, server_address):
        # Create a listening socket
        self.listen_socket = listen_socket = socket.socket(
            self.address_family,
            self.socket_type
        )
        # Allow to reuse the same address
        listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        # Bind
        listen_socket.bind(server_address)
        # Activate
        listen_socket.listen(self.request_queue_size)
        # Get server host name and …
Run Code Online (Sandbox Code Playgroud)

python wsgi wsgiserver

0
推荐指数
1
解决办法
2628
查看次数

标签 统计

wsgiserver ×7

python ×5

bottle ×2

flask ×2

cherrypy ×1

deployment ×1

django ×1

fastcgi ×1

gevent ×1

python-3.x ×1

ssl ×1

wsgi ×1