-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·30 lines (22 loc) · 866 Bytes
/
run.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from app import create_app
from app.helpers import project_name, slugify
application = create_app()
if __name__ == '__main__':
from app.factory import environment
app_name = application.config['APP_NAME']
server = application.config['SERVER_NAME'].split(':')
assert 1 <= len(server) <= 2, "SERVER_NAME in settings should be like 'example.com' or 'localhost:5000', not: {}".format(server)
host = server[0]
port = int(server[1]) if len(server) == 2 else 80
env = environment()
print(("INFO Starting '{app}' ({env_var_prefix}) on {host}:{port} using environment '{env}'".format(**dict(
app=app_name,
env_var_prefix=slugify(project_name, '_').upper(),
host=host,
port=port,
env=env,
))))
application.run(host=host, port=port)