-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (26 loc) · 887 Bytes
/
Copy pathapp.py
File metadata and controls
32 lines (26 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import FileResponse
from pyramid.view import view_config
import my_barcode
@view_config(
route_name='barcode',
renderer='templates/barcode.jinja2')
def barcode(request):
return []
@view_config(
route_name='barcode',
request_method='POST')
def post(request):
nr_eans = my_barcode.upload_to_tuple(request.POST['file'].file)
eans = my_barcode.create_eans(nr_eans)
myzip = my_barcode.create_zipfile(eans)
return FileResponse(myzip, content_type='application/zip')
if __name__ == '__main__':
with Configurator() as config:
config.include('pyramid_jinja2')
config.add_route('barcode', '/')
config.scan()
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()