Esempio n. 1
0
def graph(env, start_response):
	start_response('200 Ok', [('Content-type', 'image/png')])
	now = int(time.time())
	graph_range = (3600*24)
	rrdtool.graph('uwsgi_graph.png', '--start', str(now - graph_range), '--end', str(now), 'DEF:urequests=test.rrd:requests:AVERAGE', 'LINE2:urequests#00FF00')
	# send file to client
	uwsgi.sendfile('uwsgi_graph.png')
Esempio n. 2
0
def serve_logo(e, sr):
    # use raw facilities (status will not be set...)
    uwsgi.send(
        b"%s 200 OK\r\nContent-Type: image/png\r\n\r\n"
        % e["SERVER_PROTOCOL"].encode("latin1")
    )
    uwsgi.sendfile(logo_png)
    return []
Esempio n. 3
0
def application(env, start_response):

	boundary = 'uwsgi_mjpeg_frame'

	start_response('200 Ok', [

				('Cache-Control', 'no-cache'),
				('Cache-Control', 'private'),
				('Pragma', 'no-cache'),
				('Content-Type', 'multipart/x-mixed-replace; boundary=' + boundary),
				]
			)


	yield "--%s\n" % boundary

	while 1:
		yield "Content-Type: image/jpeg\r\n\r\n"
		uwsgi.sendfile('screenshot.jpg')
		yield "--%s\n" % boundary
Esempio n. 4
0
def serve_logo(e, sr):
    # use raw facilities (status will not be set...)
    uwsgi.send("%s 200 OK\r\nContent-Type: image/png\r\n\r\n" %
               e['SERVER_PROTOCOL'])
    uwsgi.sendfile('logo_uWSGI.png')
    return ''
Esempio n. 5
0
def serve_logo(e, sr):
    sr("200 OK", [("Content-Type", "image/png")])
    return uwsgi.sendfile(logo_png)
Esempio n. 6
0
def serve_logo(e, sr):
    # use raw facilities
    uwsgi.send("%s 200 OK\r\nContent-Type: image/png\r\n\r\n" % e['SERVER_PROTOCOL'])
    uwsgi.sendfile('logo_uWSGI.png')
    return ''
Esempio n. 7
0
def application(env, start_response):

    print(env.__class__)
    print(env['PATH_INFO'])
    print(env['REQUEST_METHOD'])
    print(env['wsgi.input'])

    if env['PATH_INFO'].startswith('/progress/'):
        start_response('200 Ok', [('Content-type', 'application/json')])
        filename = 'foobar/' + env['PATH_INFO'][10:]
        print filename
        if os.path.exists(filename):
            return uwsgi.sendfile(filename)
        else:
            return "{ 'state': 'done' }"

    if env['REQUEST_METHOD'] == 'POST':
        start_response('200 Ok', [('Content-type', 'text/plain')])
        #for x in env['wsgi.input']:
        #	yield x
        body = env['wsgi.input'].read(int(env['CONTENT_LENGTH']))
        body += env['wsgi.input'].readline()
        #print body
        body += env['wsgi.input'].read(100)
        body += env['wsgi.input'].read(100)
        body += env['wsgi.input'].read()
        return body
    else:
        start_response('200 Ok', [('Content-type', 'text/html')])
        x_progress_id = str(uuid.uuid4())
        return """
<html>
<head>
<script src="/static/jquery-1.5.1.min.js" /></script>
<script language="Javascript">
var interval;
function redrawProgressBar() {
	interval = setInterval(getData, 1000);
}

function getData() {
	var jsr = $.getJSON("/progress/%s.js",
        	function(data) {
			if (data) {
				if (data.state == 'uploading') {
					$('#progress').html(data.received + '/' + data.size);
					return;
				}
			}
			alert("fine");
			clearInterval(interval);
                }
	);
	jsr.error(function() { clearInterval(interval); });

}
</script>
</head>
<body>
upload progress: <div id="progress"> 0%%</div>
<form method="POST" enctype="multipart/form-data" action="?X-Progress-ID=%s" onsubmit="redrawProgressBar(); return true;">
	<textarea name="pluto">
	</textarea>
    <input type="file" name="pippo" />
    <input type="submit" value="invia" />
</form>
</body>
</html>
        """ % (x_progress_id, x_progress_id)
Esempio n. 8
0
def application(env, start_response):

    if env['PATH_INFO'].startswith('/progress/'):
        start_response('200 Ok', [('Content-type', 'application/json')])
        filename = 'foobar/' + env['PATH_INFO'][10:]
        print filename
       	if os.path.exists(filename): 
            return uwsgi.sendfile(filename)
        else:
            return "{ 'state': 'done' }"
	

    if env['REQUEST_METHOD'] == 'POST':
    	start_response('200 Ok', [('Content-type', 'text/plain')])
	#for x in env['wsgi.input']:
	#	yield x
	body = env['wsgi.input'].read(int(env['CONTENT_LENGTH']))
	body += env['wsgi.input'].readline()
	#print body
	body += env['wsgi.input'].read(100)
	body += env['wsgi.input'].read(100)
	body += env['wsgi.input'].read()
	return body
    else:
    	start_response('200 Ok', [('Content-type', 'text/html')])
        x_progress_id = str(uuid.uuid4())
        return """
<html>
<head>
<script src="/static/jquery-1.5.1.min.js" /></script>
<script language="Javascript">
var interval;
function redrawProgressBar() {
	interval = setInterval(getData, 1000);
}

function getData() {
	var jsr = $.getJSON("/progress/%s.js",
        	function(data) {
			if (data) {
				if (data.state == 'uploading') {
					$('#progress').html(data.received + '/' + data.size);
					return;
				}
			}
			alert("fine");
			clearInterval(interval);
                }
	);
	jsr.error(function() { clearInterval(interval); });

}
</script>
</head>
<body>
upload progress: <div id="progress"> 0%%</div>
<form method="POST" enctype="multipart/form-data" action="?X-Progress-ID=%s" onsubmit="redrawProgressBar(); return true;">
	<textarea name="pluto">
	</textarea>
    <input type="file" name="pippo" />
    <input type="submit" value="invia" />
</form>
</body>
</html>
        """ % (x_progress_id, x_progress_id)
Esempio n. 9
0
def serve_logo(e, sr):
    sr('200 OK', [('Content-Type', 'image/png')])
    return uwsgi.sendfile('logo_uWSGI.png')
Esempio n. 10
0
def serve_logo(e, sr):
    sr('200 OK', [('Content-Type', 'image/png')])
    return uwsgi.sendfile('logo_uWSGI.png')
Esempio n. 11
0
def serve_logo(e, sr):
    sr("200 OK", [("Content-Type", "image/png")])
    return uwsgi.sendfile("logo_uWSGI.png")