forked from Zaunei/flathunter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
35 lines (29 loc) · 1.21 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
""" Startup file for Google Cloud deployment or local webserver"""
from flathunter.idmaintainer import IdMaintainer
from flathunter.googlecloud_idmaintainer import GoogleCloudIdMaintainer
from flathunter.web_hunter import WebHunter
from flathunter.config import Config
from flathunter.web import app
config = Config()
if __name__ == '__main__':
# Use the SQLite DB file if we are running locally
id_watch = IdMaintainer('%s/processed_ids.db' % config.database_location())
else:
# Use Google Cloud DB if we run on the cloud
id_watch = GoogleCloudIdMaintainer()
hunter = WebHunter(config, id_watch)
app.config["HUNTER"] = hunter
if 'website' in config:
app.secret_key = config['website']['session_key']
app.config["DOMAIN"] = config['website']['domain']
app.config["BOT_NAME"] = config['website']['bot_name']
else:
app.secret_key = b'Not a secret'
notifiers = config["notifiers"]
if "telegram" in notifiers:
app.config["BOT_TOKEN"] = config['telegram']['bot_token']
if "mattermost" in notifiers:
app.config["MM_WEBHOOK_URL"] = config['mattermost']['webhook_url']
if __name__ == '__main__':
listen = config['website']['listen']
app.run(host=listen['host'], port=listen['port'], debug=True)