forked from sbg/seventweets
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwsgi.py
43 lines (34 loc) · 1.29 KB
/
wsgi.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
import yaml
import logging
from flask import Flask
from seventweets.server import Server
from seventweets.tweets_blueprint import tweets_blueprint
from seventweets.register_blueprint import register_blueprint
logger = logging.getLogger(__name__)
class MyFlask(Flask):
"""
Custom Flask class. Instantiates and runs Server before app.run()
When loading different server configs, path to config needs to be changed
"""
def __init__(self, *args, **kwargs):
with open("config/server1.yaml", 'r') as ymlfile:
cfg = yaml.load(ymlfile)
server_name = cfg['server']['server_name']
database = cfg['server']['database']
my_address = cfg['server']['my_address']
serving_at_port = cfg['server']['serving_at_port']
connect_to = cfg['server']['connect_to']
server = Server(
server_name=server_name,
database=database,
my_address=my_address,
serving_at_port=serving_at_port,
connect_to=connect_to
)
server.run(production=True)
super(MyFlask, self).__init__(*args, **kwargs)
application = MyFlask(__name__)
application.register_blueprint(register_blueprint)
application.register_blueprint(tweets_blueprint)
if __name__ == "__main__":
application.run()