app.py 340 B

123456789101112131415161718
  1. import multiprocessing
  2. import mrhttp
  3. import mrjson as json
  4. app = mrhttp.Application()
  5. @app.route('/json', _type="json")
  6. def j(r):
  7. return json.dumps({'message': 'Hello, world!'})
  8. @app.route('/plaintext', _type="text", options=['cache'])
  9. def p(r):
  10. return "Hello, world!"
  11. app.run('0.0.0.0', 8080, cores=multiprocessing.cpu_count())