This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.web import server, resource | |
from twisted.web.static import File | |
from twisted.internet import reactor | |
resource = File('/home/uploads/') | |
reactor.listenTCP(8080, server.Site(resource)) | |
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.web import server, resource | |
from twisted.internet import reactor | |
class HelloResource(resource.Resource): | |
isLeaf = True | |
def render_GET(self, request): | |
request.setHeader("content-type", "text/plain") | |
return "I am a stupid HTTP server!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
require 'evma_httpserver' | |
class MyHttpServer < EM::Connection | |
include EM::HttpServer | |
def post_init | |
super | |
no_environment_strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.options | |
import tornado.web | |
from tornado.options import define, options | |
define("port", default=8080, help="run on the given port", type=int) | |
def main(): | |
tornado.options.parse_command_line() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.options | |
import tornado.web | |
from tornado.options import define, options | |
define("port", default=8080, help="run on the given port", type=int) | |
class MainHandler(tornado.web.RequestHandler): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
from eventlet import wsgi | |
import os.path | |
upload_dir = '/home/uploads/' | |
def application(environ, start_response): | |
path = environ['PATH_INFO'] | |
if not os.path.isfile(upload_dir + path): | |
start_response("404 Not Found", [('Content-type', 'text/plain')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
from eventlet import wsgi | |
def application(environ, start_response): | |
start_response('200 OK', [('Content-Type', 'text/plain')]) | |
return ['I am a stupid HTTP server!'] | |
wsgi.server(eventlet.listen(('', 8080)), application, log_output=None, debug=False, max_size=10000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gevent import monkey; monkey.patch_all() | |
from gevent.pywsgi import WSGIServer | |
from pymongo import MongoClient | |
from gridfs import GridFS | |
from gridfs.errors import NoFile | |
#from bson import ObjectId | |
import sys | |
db = MongoClient(max_pool_size=15).example | |
fs = GridFS(db) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gevent import monkey; monkey.patch_all() | |
from gevent.pywsgi import WSGIServer | |
import os.path | |
upload_dir = '/home/uploads/' | |
def application(environ, start_response): | |
path = environ['PATH_INFO'] | |
if not os.path.isfile(upload_dir + path): | |
start_response("404 Not Found", [('Content-type', 'text/plain')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gevent import monkey; monkey.patch_all() | |
from gevent.pywsgi import WSGIServer | |
def application(environ, start_response): | |
start_response('200 OK', [('Content-Type', 'text/plain')]) | |
return [b'I am a stupid HTTP server!'] | |
if __name__ == '__main__': | |
WSGIServer(('', 8080), application, log=None).serve_forever() |
NewerOlder