from mrhttp import app @app.route('/') def hello(r): if r.file == None: return "No file uploaded" #for f in r.files: #print(f) name = r.file['name'] typ = r.file['type'] body = r.file['body'] return name app.run(cores=4) # curl -i -X POST -F "data=@14_upload.py" http://localhost:8080/
from mrhttp import app app.err404 = "My 404 page" @app.route('/') def hello(request): return 'Hello World!' app.run(cores=2) # curl -i --raw http://localhost:8080/notfound
print(line) print(line.strip()) if line.strip() == b'': break lines.append(line) w.close() app.stop() @app.route('/') async def index(r): return "test" try: app.run(cores=1, port=41111) except Exception as e: print("YAY", e) #def test_bad_request_response(): #app = Sanic('test_bad_request_response') #lines = [] #@app.listener('after_server_start') #async def _request(sanic, loop): #connect = asyncio.open_connection('127.0.0.1', 42101) #reader, writer = await connect #writer.write(b'not http') #while True: #line = await reader.readline() #if not line: #break