-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
97 lines (82 loc) · 3.38 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import logging
import string
import wsgiref.handlers
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp \
import template
from util.sessions import Session
from dbinterface import DataStoreInterface
from profiles import *
from register import RegisterHandler
from cpanel import *
from settings import SettingsHandler
from retrievepass import RetrievePassHandler
from twittercallback import TwitterCallbackHandler
from update import UpdateHandler
from fbauth import *
from logout import LogOutHandler
from mobile import MobileHandler
from contact import ContactHandler
from testEmail import EmailHandler
from reply import *
from postAction import postActionHandler
from util.twitter_oauth_handler import *
from dbinterface import *
import render
class MainHandler(webapp.RequestHandler):
def get(self):
path = (self.request.path).replace('/', '')
datastore = DataStoreInterface()
if (path <> '') and (path <> 'main.html'):
if (datastore.companyProfileExists(path) == 1):
path = 'profiles.html?company='+path
self.redirect(path)
else:
self.response.out.write('404: File not Found')
else:
render.doRender(self,'main.html', {})
def post(self):
self.session = Session()
datastore = DataStoreInterface()
email = self.request.get('txtEmail').strip()
password = self.request.get('txtPassword')
self.session.delete_item('user')
#Check for any fields left empty
if email == '' or password == '':
render.doRender(self, 'main.html', {'error' : 'Please fill in all the details'})
return
username = datastore.loginUser(email, password)
if datastore.isUser(email)== 1:
if datastore.checkPass(email, password)==1:
self.session['user'] = username
self.redirect('controlpanel.html')
else:
render.doRender(self, 'main.html', {'error' : 'Wrong password'})
else:
render.doRender(self, 'main.html', {'error' : 'Email Address does not exist'})
def main():
application = webapp.WSGIApplication([('/facebook/', FbAuthHandler),
('/facebook/callback/', FbCallbackHandler),
('/fbauthorized/.*', FbSessionHandler),
('/register.html', RegisterHandler),
('/controlpanel.html', CPanelHandler),
('/profiles.html', ProfilesHandler),
('/settings.html', SettingsHandler),
('/retrieve.html', RetrievePassHandler),
('/update.html', UpdateHandler),
('/mobile', MobileHandler),
('/contact.html', ContactHandler),
('/postAction', postActionHandler),
('/twitter_oauth', TwitterCallbackHandler),
('/twitter_reply.*', TwitterReplyHandler),
('/facebook_reply.*', FacebookReplyHandler),
('/oauth/(.*)/(.*)', OAuthHandler),
('/logout', LogOutHandler),
('/email', EmailHandler),
('/img', ImageHandler),
('/.*', MainHandler)],
debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()