-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·36 lines (31 loc) · 1.16 KB
/
main.py
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
33
34
35
36
'''
Main application:
- Before running this program make sure to run db_creation.py first.
In case you have already done it, you are good to go! :)
- Install geruquote lib from geruquote folder.
- Pyramid app is created:
- routes are defined
- views are called from views.py
- server is kept running
'''
from wsgiref.simple_server import make_server
from pyramid.session import SignedCookieSessionFactory
from pyramid.config import Configurator
if __name__ == '__main__':
print ('Defining routes...')
cookie_session = SignedCookieSessionFactory('itsagoodshow')
with Configurator() as config:
config.add_route('home', '/')
config.add_route('quotes', '/quotes')
config.add_route('pick_quote', '/quotes/{quote_number}')
config.add_route('log', '/log')
config.add_route('log_id', '/log/{log_id}')
config.set_session_factory(cookie_session)
config.scan('views')
app = config.make_wsgi_app()
print('Starting server')
ip = '0.0.0.0'
port = 1234
server = make_server(ip, port, app)
print('Listening on {}:{}'.format(ip, port))
server.serve_forever()