示例#1
0
def main():

    # initialization loop just incase this server initializes before postgres
    try:
        sql.create_all()
    except OperationalError:
        logging.error('Unable to connect to database. Trying again ...')
        time.sleep(1)
        main()
    except KeyboardInterrupt:
        exit()

    connex_app.add_api('openapi.yml')
    connex_app.run(host='0.0.0.0', port=5001, debug=True)
示例#2
0
from flask_migrate import Migrate
from config import db, connex_app

migrate = Migrate(connex_app.app, db)
connex_app.add_api("swagger.yml")


@connex_app.route("/")
def index():
    return "<h4>Job Monitoring by Reagan Balongcas, GRID Trainee</h4>"


if __name__ == "__main__":
    connex_app.run()
示例#3
0
#!/usr/bin/env python3
"""
Main module of the server file
"""

import connexion
from config import connex_app as app
from params import cfg

# Read the swagger.yml file to configure the endpoints
app.add_api("swagger.yml")


# create a URL route in our application for "/"
@app.route("/")
def home():
    return "Server up and running."


if __name__ == "__main__":
    app.debug = cfg['debug']
    app.run(host=cfg['host'], port=cfg['port'], ssl_context=cfg['ssl_context'])
示例#4
0
import os.path
from config import base_dir, connex_app, app

connex_app.add_api(os.path.join(base_dir, 'swagger.yaml'))

if __name__ == '__main__':
    app.run(debug=True, port=5207)
示例#5
0
from config import connex_app
from config import SIM_CONTROLLER, USE_SIMULATION, SIM_REGISTER_FROM_DATABASE
from flask import render_template
from queue import Queue
from classes.TCPThread import TCPThread
from classes.HomeLynkController import HomeLynkController
from classes.simulation.devices.lamp import Lamp

connex_app.add_api('objects.yml')
"""Add the yml file to the api
"""


@connex_app.route('/')
def home():
    """
    This function just responds to the browser ULR
    localhost:5000/
    :return:        the rendered template 'index.html'
    """
    return render_template('index.html')


# If we're running in stand alone mode, run the application
if __name__ == '__main__':
    q = Queue()
    HLController = HomeLynkController(q)
    HLController.daemon = True
    HLController.start()
    if USE_SIMULATION:
        SIM_CONTROLLER.set_queue(q)
示例#6
0
from flask import render_template
from config import connex_app

connex_app.add_api('swagger.yml')
@connex_app.route('/')
def home():
    return render_template('home.html')

if __name__ == '__main__':
    connex_app.run(host='0.0.0.0', port=5000, debug=True)