forked from pupubird/Python_email_marketing_Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
62 lines (50 loc) · 1.77 KB
/
app.py
File metadata and controls
62 lines (50 loc) · 1.77 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
import os
import tornado.ioloop
import tornado.web as web
import webbrowser
import start_smtp_server
import compile_external_html
import send_emails
import authenticate
import editPageHandler
import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # python-3.8.0a4
public_root = os.path.dirname(os.path.realpath(__file__)) + r'\\static\\'
ROOT = os.path.dirname(os.path.realpath(__file__)) + r'\\root\\'
OUTPUT_STATIC = os.path.dirname(os.path.realpath(__file__)) + r'\\static\\'
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.render('index.html')
handlers = [
(r'/', MainHandler),
(r'/authenticate', authenticate.authenticateHandler),
(r'/edit', editPageHandler.editPageHandler),
(r'/sendEmails', send_emails.sendEmailsHandler),
(r'/', web.StaticFileHandler, {'path': public_root}),
]
settings = dict(
static_path=public_root,
template_path=public_root
)
if __name__ == "__main__":
application = web.Application(handlers, **settings)
# Clean up every file for later compiling
os.makedirs(OUTPUT_STATIC, exist_ok=True)
for filename in os.listdir(OUTPUT_STATIC):
if '.html' in filename:
os.remove(OUTPUT_STATIC+filename)
# compiling into a single html file
compile_external_html.main()
http_port = 7777
print("""
_________ __ __
/ _____// |______ ________/ |_
\\_____ \\\\ __\\__ \\\\_ __ \\ __\\
/ \\| | / __ \\| | \\/| |
/_______ /|__| (____ /__| |__|
\\/ \\/
""")
print(f"Starting HTTP Server at port {http_port}")
application.listen(http_port)
webbrowser.open_new_tab(f"http://localhost:{http_port}/")
tornado.ioloop.IOLoop.instance().start()