Пример #1
0
from src.server import Server
from flask import render_template

# create a new instance of the Server
app = Server().app


# set the response headers
@app.after_request
def add_header(r):
    # Add headers to both force latest IE rendering engine or Chrome Frame,
    # and also to cache the rendered page for 10 minutes.

    r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
    r.headers["Pragma"] = "no-cache"
    r.headers["Expires"] = "0"
    r.headers['Cache-Control'] = 'public, max-age=0'
    return r


# run the server if the app.py file is the main entry point
if __name__ == '__main__':
    app.jinja_env.auto_reload = True
    app.config['TEMPLATES_AUTO_RELOAD'] = True

    app.run()
Пример #2
0
import argparse
import os
import sys

from src.server import Server
from router import urls

# try:
#     app_id = os.environ['APP_ID']
# except KeyError:
#     sys.exit('Variable APP_ID is not setted. exit')

parser = argparse.ArgumentParser()
parser.add_argument('--host')
parser.add_argument('--port')
args = parser.parse_args()

custom_server_params = {}
# TODO may be validation for passed arguments?
if args.host is not None:
    custom_server_params['host'] = args.host

if args.port is not None:
    custom_server_params['port'] = int(args.port)

server = Server(urls=urls, **custom_server_params)

server.run()
Пример #3
0
import sys

from src.server import Server

port = sys.argv[1]

Server.run(port)
Пример #4
0
from src.server import Server
Server.run()