Exemplo n.º 1
0
def index():
    '''
        Main page
    '''

    page_number = int(
        request.args.get('page_num')) if request.args.get('page_num') else 1

    return render_template(
        "index.html",
        page_number=page_number,
        results=get_data_from_database(
            page_number, results_per_page=RESULTS_PER_PAGE
        ),  # Load freshly downloaded information from database
        pages_available=get_number_of_pages_to_show(RESULTS_PER_PAGE)
    )  # Get the total number of pages available to show links for

    if __name__ == "__main__":
        application.run(host='0.0.0.0', port='8080')
Exemplo n.º 2
0
#!/usr/bin/env python3

import sys
import os
from app import application

OGGM_DASH_DIR = os.path.dirname(os.path.realpath(__file__))
os.chdir(OGGM_DASH_DIR)
sys.path.insert(0, OGGM_DASH_DIR)

if __name__ == '__main__':
    application.run(debug=True, threaded=True)
Exemplo n.º 3
0
def runserver():
    if not os.path.exists('database.db'):
        db_reset()
    application.config['HOST'] = 'localhost:5000/'
    application.register_blueprint(routes.api, url_prefix='/')
    application.run(host='localhost', port=5000, debug=True)
Exemplo n.º 4
0

# some bits of text for the page.
header_text = '''
    <html>\n<head> <title>EB Flask Test</title> </head>\n<body>'''
instructions = '''
    <p><em>Hint</em>: This is a RESTful web service! Append a username
    to the URL (for example: <code>/Thelonious</code>) to say hello to
    someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'

'''
# add a rule for the index page.
application.add_url_rule('/', 'index', (lambda: header_text +
    say_hello() + instructions + footer_text))

# add a rule when the page is accessed with a name appended to the site
# URL.
application.add_url_rule('/<username>', 'hello', (lambda username:
    header_text + say_hello(username) + home_link + footer_text))
'''

# run the app.
if __name__ == "__main__":
    # Setting debug to True enables debug output. This line should be
    # removed before deploying a production app.
    db.create_all()
    application.debug = True
    application.run(ssl_context=('./ssl.crt', './ssl.key'))
Exemplo n.º 5
0
#!flask/bin/python

from app import application
import config

if __name__ == '__main__':
	application.run(debug=config.APP_DEBUG)
Exemplo n.º 6
0
from app import application, initialize_app

initialize_app(application)

if __name__ == "__main__":
    application.run()
Exemplo n.º 7
0
from app import application

__author__ = "ahmedali"

if __name__ == "__main__":
    application.run(host='0.0.0.0', port=8080, debug=True)

Exemplo n.º 8
0
from app import application

if __name__ == "__main__":
    application.run('0.0.0.0', port=5000)
#!flask/bin/python
from flask import Flask
import os

from app import application

# Run the application with test server if in local machine
if __name__ == "__main__":
	application.run(debug = True, port=7000, host='0.0.0.0')
Exemplo n.º 10
0
#!env/bin/python
from app import application as app
app.run(debug=True, host='0.0.0.0')
Exemplo n.º 11
0
Arquivo: run.py Projeto: deveshj4/tol
#!flask/bin/python
import os
from app import application

if __name__ == "__main__":
    port = int(os.environ.get("PORT", 5000))
    application.debug = True
    application.run(host='0.0.0.0', port=port)
Exemplo n.º 12
0
Arquivo: run.py Projeto: timoh/GoCast
import os
from app import application

if __name__ == "__main__":
    app_port = int(os.environ.get("PORT", 5000))
    application.run(debug=True, host="0.0.0.0", port=app_port)
Exemplo n.º 13
0
from app import application as app

if __name__ == "__main__":
    app.run(host = '0.0.0.0', port = 8000)
Exemplo n.º 14
0
from app import application

if __name__ == "__main__":
    application.run(host='127.0.0.1', port='8000')
    #application.run(debug=False)
Exemplo n.º 15
0
#!/usr/bin/env python
from app import application


application.run(debug=True, host='0.0.0.0')
Exemplo n.º 16
0
from app import application

appHost = '0.0.0.0'

if __name__ == '__main__':
    application.run(host=appHost)
Exemplo n.º 17
0
from app import application

if __name__ == "__main__":
    application.run(host='0.0.0.0', port=80)
Exemplo n.º 18
0
    try:
        subprocess.call(['gunicorn', '-c', c, a])
        logger.info('gunicorn start-up complete')
    except RuntimeError as e:
        print('Failed to start-up application server, exiting')
        logger.error('Failed to start-up gunicorn, exiting. Consider putting application into debug mode' + e)
        quit()
elif x=='1':
    import requests
    print('Web application is disabled and will take alternitive action')
    try:
        logger.info('Web application is manually disabled, redirecing request to rnchapman.directory')
        r = requests.get('https://www.rnchapman.directory', timeout=0.005)
        r.url
    except ConnectionError as e:
        print('Connection error or no response')
        r = "No response"
        logger.error('Web application is manually disabled and a connection error occured' + e)
        quit()
elif x=='2':
    print('Starting web application in debug mode')
    logger.debug('Starting flask app server in debug mode')
    # Run the Flask app server
    from flask import Flask
    from app import application
    application.run(host='0.0.0.0', port=8080, debug=True)
else:
    print('Invalid start-up configuration')
    logger.critical('Invalid start-up configuration for run.py, quitting')
    quit()
Exemplo n.º 19
0
from app import application, db
# import all your table model here
from app.models import User


@application.shell_context_processor
def make_shell_context():
    return {'db': db, 'User': User}


if __name__ == "__main__":
    application.run(host="0.0.0.0", port=8080, debug=True)
Exemplo n.º 20
0
from app import application, db
from app.models import User, Post


@application.shell_context_processor
def make_shell_context():
    return {'db': db, 'User': User, 'Post': Post}


if __name__ == "__main__":
    application.run(debug=False, host='0.0.0.0')
Exemplo n.º 21
0

@application.route("/log/add", methods=["POST"])
def addLog():
    if request.method == "POST":
        userID = request.json["userID"]
        cacheID = request.json["cacheID"]
        k = db.session.query(models.Geocache).filter(models.Geocache.id == cacheID)
        c = 0
        for i in k:
            c = i
        l = db.session.query(models.User).filter(models.User.id == userID)
        u = 0
        for j in l:
            u = j
        c.loggedUsers.append(u)
        try:
            db.session.commit()
            return "Added log!"
        except:
            return "Error adding log!"


if __name__ == "__main__":
    manager = flask.ext.restless.APIManager(application, flask_sqlalchemy_db=db)
    manager.create_api(models.User, methods=["GET", "POST", "DELETE"])
    manager.create_api(models.Geocache, methods=["GET", "POST", "DELETE"])
    application.run()

##search query: http://localhost:5000/api/user?q={%22filters%22:[{%22name%22:%22nickname%22,%22op%22:%22eq%22,%22val%22:%22kokhouser%22},{%22name%22:%22password%22,%22op%22:%22eq%22,%22val%22:%22test%22}]}
Exemplo n.º 22
0
from app import application, db
from app.blueprint.ocrreader.views import ocr_reader
from app.blueprint.ocrreader.models import RecognitionResult
from config import ddl, port_number
from constants import DDLMode
from flask_cors import CORS

application.register_blueprint(ocr_reader, url_prefix='/ocrreaders')

if ddl is DDLMode.CREATE:
    db.create_all()
    db.session.commit()
elif ddl is DDLMode.CREATE_DROP:
    db.drop_all()
    db.create_all()
    db.session.commit()

CORS(application)
application.run(port=port_number)
Exemplo n.º 23
0
from app import application
from app import config

config.init_logging()

if __name__ == '__main__':
    application.run(debug=True, host='0.0.0.0', port=52961, threaded=True)

Exemplo n.º 24
0
from app import application

if __name__ == '__main__':
    application.run(debug=True)
Exemplo n.º 25
0
    dbc.Row([tripleColumn, washHandsC, tripleColumn]),
    dbc.Row([tripleColumn, distanceCenter, tripleColumn]),
    dbc.Row([singleColumn, recsCenter, singleColumn]),
    html.Hr(),
    footer,
])


@app.callback(Output("loading-output", "children"),
              [Input("loading-button", "n_clicks")])
# URL Routing for Multi-Page Apps: https://dash.plot.ly/urls
@app.callback(Output('page-content', 'children'), [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == '/':
        return index.layout
    elif pathname == '/todo':
        return todo.layout
    elif pathname == '/peace':
        return peace.layout
    elif pathname == '/reflection':
        return reflection.layout
    elif pathname == '/shopping':
        return shopping.layout
    else:
        return dcc.Markdown('## Page not found')


# Run app server: https://dash.plot.ly/getting-started
if __name__ == '__main__':
    application.run(debug=False)
Exemplo n.º 26
0
# #!env/bin/python
import sys

import locale

locale.setlocale(locale.LC_ALL, 'ru_RU.UTF-8')

reload(sys)

sys.setdefaultencoding('utf-8')

# RUN APPLICATION
from app import application

if __name__ == '__main__':
    application.run(threaded=True)
Exemplo n.º 27
0
from app import application
import os

if __name__ == "__main__":
    port = int(os.getenv('PORT', 5000))
    application.run(debug=False, port=port, host='0.0.0.0', threaded=True)
Exemplo n.º 28
0
# some bits of text for the page.
header_text = '''
    <html>\n<head> <title>Traffic message generator</title> </head>\n<body>'''
instructions = '''<img src="/static/traffic.jpg"/>
    <p><em>Hint</em>: This is a RESTful web service! Call the service by appending <code>
    /traffic</code> to the url.
    This will generate a single message.</p><p>Add the request parameter
    <code>count=</code> to specify the number of messages to generate.</p>\n
    <p>Add the request parameter <code>randomlocation=true</code> to specify to generate a random location.</p>\n
    <p>Add the request parameter <code>roadnumber=</code> to specify to the road number to choose from 
    (eg. &amp;roadnumber=A12).</p>\n
    <p>Add the request parameter <code>starttime=</code> to specify the timestamp to start at (format: 
    YYYY-MM-DDTHH:MM:SSZ).</p>\n
    <p>Example: .../traffic?count=100 to generate 100 messages.</p>\n
    <p>Example: .../traffic?count=100&amp;randomlocation=true to generate 100 messages with a random location.</p>
    <p>Example: .../traffic?count=10&amp;stepsize=5000 to generate 100 messages with 5 seconds between each generated message timestamp.</p>\n
    '''
footer_text = '</body>\n</html>'

# add a rule for the index page.
application.add_url_rule('/', 'index',
                         (lambda: header_text + instructions + footer_text))

# run the app.
if __name__ == "__main__":
    # Setting debug to True enables debug output. This line should be
    # removed before deploying a production app.
    application.debug = True
    application.run(host='', port=8080)
Exemplo n.º 29
0
#
# WSGI file
#

from app import application

HOST = '0.0.0.0'
PORT = '8000'

if __name__ == '__main__':
    application.run(host=HOST, port=PORT)
Exemplo n.º 30
0
#! python3.4
import sys
from app import application, config

if __name__ == '__main__':
    application.run(debug=config['app']['debug'], host=config['flask']['HOST'], port=config['flask']['PORT'])
Exemplo n.º 31
0
from app import application
from users import Users
from flask import render_template


@application.route('/list')
def index():
    users = Users.query.order_by(Users.id).all()
    return render_template('list.html', users=users)


if __name__ == '__main__':
    application.run(host='0.0.0.0', port='8080')
Exemplo n.º 32
0
from app import application

if __name__ == "__main__":
    application.run(host='0.0.0.0', port='5000')
Exemplo n.º 33
0
from app import application
if __name__ == "__main__":
    application.run(host="0.0.0.0", port=5000)
Exemplo n.º 34
0
Arquivo: main.py Projeto: J4stEu/engs
from app import application
from app import db
#from app import migrate, manager
import view
import api

if __name__ == '__main__':
    application.run(host='192.168.31.247')
    #manager.run()
Exemplo n.º 35
0
from app import application

if __name__ == '__main__':
  application.run(host='0.0.0.0')
Exemplo n.º 36
0
from app import application, flask_db, database

from models import *
from views import *

def create_tables():
    # Create table for each model if it does not exist.
    database.create_tables([Entry, Tag, EntryTags, FTSEntry], safe=True)


if __name__ == '__main__':
    create_tables()
    # Run on port 8000 for Sandstorm
    application.run(host='0.0.0.0', port=8000)
Exemplo n.º 37
0
from app import application, database
from app.models import User, Operation


@application.shell_context_processor
def make_shell_context():
    return {'database': database, 'User': User, 'Operation': Operation}


# app.run(debug=True)
application.run(host='0.0.0.0')
Exemplo n.º 38
0
#!/usr/bin/env python
    
from app import application
from app.template_tags import render_collaborative, render_skill

application.jinja_env.globals["render_collaborative"] = render_collaborative
application.jinja_env.globals["render_skill"] = render_skill

if __name__ == '__main__':
    application.run(host='0.0.0.0', debug=True)
Exemplo n.º 39
0
from app import application

if __name__ == "__main__":
    application.run(host='192.168.2.131')
Exemplo n.º 40
0
  # ~with open(virtualenv, 'rb') as exec_file:
    # ~file_contents = exec_file.read()
  # ~compiled_code = compile(file_contents, virtualenv, 'exec')
  # ~exec(compiled_code, exec_namespace)
# ~except IOError:
  # ~pass


from gevent.wsgi import WSGIServer
from app import application


ip = os.environ.get('OPENSHIFT_PYTHON_IP', 'localhost')
port = int(os.environ.get('OPENSHIFT_PYTHON_PORT', 8051))
host_name = os.environ.get('OPENSHIFT_GEAR_DNS', '')

application.run(host=ip, port=port, server='gevent')
# ~application.run(server='gevent')

# ~http_server = WSGIServer((ip, port), application)
# ~http_server.serve_forever()
#
# Below for testing only
#
# ~if __name__ == '__main__':
    # ~from wsgiref.simple_server import make_server
    # ~httpd = make_server('localhost', 8051, application)
    # Wait for a single request, serve it and quit.
    # ~httpd.handle_request()
    # ~httpd.serve_forever()
Exemplo n.º 41
0
#!/usr/bin/python
from app import application

application.run(debug=True)
Exemplo n.º 42
0
    dialog = Dialog.fromJSON(loads(d.read()))

with open(etcPath + '/config.json', 'r') as c:
    config = Configuration.fromJSON(loads(c.read()))

# add required packages to sys.path
for pkg in config['server']['required']:
    if not pkg in path:
        path.insert(0, basePath + pkg)

# prepare log
from log import Log
log = Log.fromConfig(config['server']['log'])

# prepare flask, sqlalchemy, marshmallow, and wtforms
from app import application
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
application.config['SQLALCHEMY_DATABASE_URI'] = connectionString
application.config['SECRET_KEY'] = config['server']['secretKey']
db = SQLAlchemy(application)
ma = Marshmallow(application)

# deploy wsgi server
if __name__ == '__main__':
    __import__('db') # load schalchemy classes
    __import__('sess') # load marshmallow and wtform classes
    engine = db.create_engine(connectionString, {})
    db.Model.metadata.create_all(engine)
    application.run(host='0.0.0.0', port=5000, debug=False)
Exemplo n.º 43
0
from app import application

if __name__ == "__main__":
    application.run(host='127.0.0.1:5000')
Exemplo n.º 44
0
from app import application

if __name__ == "__main__":
    application.run(host="0.0.0.0", port="8080")
from app import application

if __name__ == "__main__":
    application.run(host='0.0.0.0',
                    port=80,
                    debug=application.config['DEBUG_MODE'],
                    use_reloader=application.config['DEBUG_MODE'])
            'Public and Social Services', 'Science, Math, and Technology',
            'Social Sciences', 'Trades and Personal Services'
        ]
        for name in names_to_format:
            result_output[name] = result_output[name].map('{:,.2%}'.format)

        # also fill na with ''
        result_output = result_output.fillna('N/A')
        result_output['Admission rate'] = result_output[
            'Admission rate'].str.replace('nan%', 'N/A')

        # transpose to output
        result_output = result_output.set_index('Name').T

        if request.method == 'POST':
            logger.info('Recommendation successfully generated.')
            return render_template('layout_predictionpage.html',
                                   data=result_output.to_html())
    except:
        logger.warning(
            'Unexpected errors in generating the recommendation page.')
        msg = 'This page was just refreshed because of unexpected errors in generating the recommendation page. Try again below!'
        return render_template('layout_homepage.html', message=msg)


if __name__ == "__main__":
    # logger initialization
    logging.basicConfig(filename='application.log', level=logging.DEBUG)
    logger = logging.getLogger(__name__)
    application.run(host='0.0.0.0', use_reloader=True, debug=True)
Exemplo n.º 47
0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import os
from dotenv import load_dotenv
import utilities

# load dotenv before loading the application
load_dotenv()

from app import application  # pylint: disable=wrong-import-position

if __name__ == '__main__':
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    PORT = utilities.normalize_port(os.getenv('PORT'))
    if PORT:
        application.run(port=PORT)
    else:
        application.run(host='0.0.0.0')
Exemplo n.º 48
0
#!/usr/bin/env python
import sys
from app import application as app


if len(sys.argv)==1:
    app.run()
else:
    from flask.ext.script import Manager
    from flask.ext.migrate import Migrate, MigrateCommand

    from app.base import db

    migrate = Migrate(app, db)
    manager = Manager(app)

    try:
        manager.add_command('base', MigrateCommand)
    except:
        pass

    manager.run()