-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteAccount.py
42 lines (37 loc) · 1.25 KB
/
deleteAccount.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
#!/usr/bin/python
import string
import connectToDatabase
import genHTML
import login
import wsgiref.handlers
import forbidden
import ok
__author__ = 'ashaw'
def deleteAccount(environ, start_response):
wasloggedin = login.isLoggedIn(login.getLoginToken(environ))
conn = connectToDatabase.connect()
c = conn.cursor()
c.execute("DELETE FROM users WHERE userid = %s", [login.getUserId(login.getLoginToken(environ))])
conn.commit()
c.close()
conn.close()
string += genHTML.genPageHeader('EngCupid')
string += genHTML.genMenuBar("EngCupid", [dict(link='browse.py', name='Browse', active=True)], login.getLoginToken(environ))
string += genHTML.beginContainer()
if wasloggedin:
string += """\
<div class='span12'>
<div class="hero-unit">
<H1>Account Deleted</H1>
<p>Your account has been removed from our system.</p>
</div>
</div>
"""
else:
return forbidden.forbidden(environ,start_response)
string += genHTML.endContainer()
string += genHTML.genPageFooter()
start_response(ok.code(), [('Content-type', 'text/html')])
return string
if __name__ == "__main__":
wsgiref.handlers.CGIHandler().run(deleteAccount)