Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. '''
  4. Test version
  5. '''
  6.  
  7. from flask import Flask
  8. from datetime import datetime
  9. import io
  10. import time
  11. import picamera
  12. import logging
  13. import sys
  14. import os
  15.  
  16. app = Flask(__name__)
  17.  
  18. logging.basicConfig(level=logging.INFO,
  19. format='%(asctime)s %(levelname)-8s '
  20. + '[%(filename)s:%(lineno)s:%(funcName)s()] %(message)s',
  21. datefmt='%Y-%m-%d %H:%M:%S')
  22.  
  23. @app.route("/start", methods=['POST'])
  24. def start_capture():
  25. with picamera.PiCamera() as camera:
  26. camera.resolution = (1920, 1080)
  27. camera.start_preview()
  28. time.sleep(300)
  29. pass
  30.  
  31. @app.route("/stop", method=['POST'])
  32. def stop_capture():
  33. with picamera.PiCamera() as camera:
  34. camera.stop_preview()
  35. pass
  36.  
  37. @app.route("/screenshot", methods=['POST'])
  38. def screenshot():
  39. with picamera.PiCamera() as camera:
  40. camera.capture('foo.jpg', use_video_port=True)
  41. pass
  42.  
  43. if __name__ == "__main__":
  44. app.run(host='192.168.0.198', port='8080')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement