Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webserver #103

Open
wants to merge 18 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
# photobooth

Initiator:
[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/black_img.png)](https://www.buymeacoffee.com/reuterbal)

Forker:
[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/black_img.png)](http://buymeacoff.ee/oelegeirnaert)

I'm thirsty as well!

## Edits by Oele Geirnaert:

### Webinterface features
* When a new picture has been taken, it's automatically added to the Gallery & Slideshow via an API.
* A notification will popup in the gallery/slideshow that a new picture has been taken to motivate the people to take a selfie.
* Mail functionality via Mailgun
* Delete picture
* Generate QR code with links:
* QR code to show link
* QR code to mail the picture
* QR code to download the picture
* Keyboard shortcuts:
* **'g'**: Go to gallery
* **'s'**: Start slideshow
* **'esc'**: Go to index
* Added rand() function to safely store the picture on the webserver
* Web Views:
* Gallery-mode: This view is for administration purposes to view, mail, download, show qr codes to download/mail, print, delete a picture
* Slideshow-mode: This view may be used to show all the pictures on a projector in a room.
* Show only last picture mode: Last taken picture is shown + two QR codes to download/mail the picture) - This view may be set at the outside of the photobooth.

- [ ] Security (That not everybody is able to get the gallery via the webserver)
- [ ] NFC
- [ ] Photobooth status (Free or Available with movement detector & GPIO)
- [ ] Other Improvements
- [ ] As this program becomes bigger and complexer, unit- & functional tests should be written.
- [ ] Inverse the default startup params (--gui must be set right now in orde to show the gui. -w activates the webserver. The way I run it the most: **python -m photobooth -w --gui** and while developing the webserver: **python -m photobooth --debug -w**)



### Screenshots
<img alt="Example of gallery" title="Idle screen" src="screenshots/photobooth_gallery.png" width="500" />
<img alt="Example of slideshow" title="Idle screen" src="screenshots/photobooth_slideshow.png" width="500" />
<img alt="Example of mailform" title="Idle screen" src="screenshots/photobooth_mail_form.png" width="500" />
<img alt="Example of random picture names" title="Idle screen" src="screenshots/photobooth_rand_picture.png" width="500" />
<img alt="Example of random picture names" title="Idle screen" src="screenshots/photobooth_last_picture.png" width="500" />

A flexible Photobooth software.

It supports many different camera models, the appearance can be adapted to your likings, and it runs on many different hardware setups.
Expand Down Expand Up @@ -34,7 +76,7 @@ Screenshots produced using `CameraDummy` that produces unicolor images.
* Based on [Python 3](https://www.python.org/), [Pillow](https://pillow.readthedocs.io), and [Qt5](https://www.qt.io/developers/)

### History
I started this project for my own wedding in 2015.
I started this project for my own wedding in 2015.
See [Version 0.1](https://github.com/reuterbal/photobooth/tree/v0.1) for the original version.
Github user [hackerb9](https://github.com/hackerb9/photobooth) forked this version and added a print functionality.
However, I was not happy with the original software design and the limited options provided by the previously used [pygame](https://www.pygame.org) GUI library and thus abandoned the original version.
Expand Down
42 changes: 37 additions & 5 deletions photobooth/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .StateMachine import Context, ErrorEvent
from .Threading import Communicator, Workers
from .worker import Worker
from .webserver import Webserver

# Globally install gettext for I18N
gettext.install('photobooth', 'photobooth/locale')
Expand Down Expand Up @@ -81,11 +82,16 @@ def __init__(self, argv, config, comm):
self._comm = comm

def run(self):
retval = None
parsed_args, unparsed_args = parseArgs(self._argv)
if parsed_args.gui:
logging.debug('Start GuiProcess')
Gui = lookup_and_import(gui.modules, self._cfg.get('Gui', 'module'),
'gui')
retval = Gui(self._argv, self._cfg, self._comm).run()
else:
logging.debug("Gui process disabled.")

logging.debug('Start GuiProcess')
Gui = lookup_and_import(gui.modules, self._cfg.get('Gui', 'module'),
'gui')
retval = Gui(self._argv, self._cfg, self._comm).run()
logging.debug('Exit GuiProcess')
return retval

Expand Down Expand Up @@ -137,6 +143,28 @@ def run(self):

logging.debug('Exit GpioProcess')

class WebServerProcess(mp.Process):
def __init__(self, argv, config, comm):
logging.debug(argv)
logging.debug(config)
logging.debug(comm)

super().__init__()
self._argv = argv
self.daemon = True
self._cfg = config
self._comm = comm

def run(self):
logging.debug("Start Webserver")
parsed_args, unparsed_args = parseArgs(self._argv)

if parsed_args.webserver:
logging.debug("Run webserver")
ws = Webserver(self._cfg, self._comm).run()
else:
logging.debug("Webserver disabled")


def parseArgs(argv):

Expand All @@ -146,6 +174,8 @@ def parseArgs(argv):
help='omit welcome screen and run photobooth')
parser.add_argument('--debug', action='store_true',
help='enable additional debug output')
parser.add_argument('--webserver', '-w', action='store_true', help='start the webserver')
parser.add_argument('--gui', '-g', action='store_true', help='start gui')
return parser.parse_known_args()


Expand All @@ -165,7 +195,9 @@ def run(argv, is_run):
# 3. GUI
# 4. Postprocessing worker
# 5. GPIO handler
proc_classes = (CameraProcess, WorkerProcess, GuiProcess, GpioProcess)

proc_classes = (CameraProcess, WorkerProcess, GuiProcess, GpioProcess, WebServerProcess)
#proc_classes = (CameraProcess, WorkerProcess, WebServerProcess)
procs = [P(argv, config, comm) for P in proc_classes]

for proc in procs:
Expand Down
Loading