-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (58 loc) · 2.58 KB
/
main.py
File metadata and controls
68 lines (58 loc) · 2.58 KB
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
from google.appengine.api import mail
from framework import bottle
from framework.bottle import *
import utilities as ut
app = Bottle()
@app.route('/<filepath:path>')
def server_static(filepath):
return static_file(filepath, root='views')
@app.get('/')
def home_index():
subjects = ut.get_subjects()
content = ut.get_content()
return bottle.template("home",subjects=subjects,keyword_list="",resultingList=[])
@app.post('/')
def search():
subjects = ut.get_subjects()
searchList = bottle.request.forms.getlist("subjects")
if len(searchList) == 0:
return bottle.template("home",subjects=subjects,keywordList=[],resultingList=[])
keywordList = ",".join(searchList)
resultingList = ut.search_journals(searchList)
return bottle.template("home",subjects=subjects,keywordList=keywordList,resultingList=resultingList)
@app.get('/contact')
def home_index():
return bottle.template("contact", dict(email="", subject="",scontent="",notification="",s="ok"))
@app.post('/contact')
def send_mail():
email = bottle.request.forms.get("email")
scontent = bottle.request.forms.get("scontent")
subject = bottle.request.forms.get("subject")
if email == "":
notification = "Please enter your e-mail address"
return bottle.template("contact", dict(email="", subject="",scontent="",notification=notification,s="warning"))
else:
# To enable mailing, you shoudl go to the application Dashboard --> Administration --> Permissions
# Add name@domain.com and check your mailbox to verify the account.
message = mail.EmailMessage(sender="JournalS Support <name@domain.com>", #name@domain.com is verified by google app engine, so it should be real
subject="Your message has been received")
message.to = email
message.bcc = "your-email@domain.com"
message.body = """
Dear Journal Seeker:
Your message has been received.
-------------------------------
"""
message.body += scontent + "\n"
message.body +="""
-------------------------------
We will contact you as soon as possible.
Keep following and keep writing :)
JournalS Team
"""
message.send()
notification = "Your message has been sent successfully."
return bottle.template("contact", dict(email="", subject="",scontent="",notification=notification,s="success"))
#If you want to debug you should use
# bottle.run(app=app, server='gae', debug=True)
bottle.run(app=app, server='gae')