def create_api_app(host='0.0.0.0', port=5000, disc='discovery.json'): app = Flask(__name__) app.register_blueprint(zabbix_api) app.register_blueprint(lag_api) app.g = { 'disc': disc, 'zabbix': None, 'zabbix_update': None, 'lag': None, 'lag_update': None } wsgi_server = WSGIServer((host, port), app, log=None) # TODO: fix empty discovery lookup junk, just ignore zabbix if it's not # present api_log.info('discovering_api_files') files = ['discovery.json', 'server.json'] while files: for fi in files: if os.path.exists(os.path.join(disc, fi)): api_log.info('found_api_file', file=fi) files.remove(fi) return wsgi_server
def create_app(): app = Flask(__name__) app.g = [0,0,0,[],{}] def gethighscore(): highscore = open('highscore','r') highscore = highscore.read() app.g[2] = highscore def setupdb(): db = open('ips','r') db = json.load(db) app.g[3] = db gethighscore() setupdb() return app
def create_app(): app = Flask(__name__) app.g = [0, 0, 0, [], {}] def gethighscore(): highscore = open('highscore', 'r') highscore = highscore.read() app.g[2] = highscore def setupdb(): db = open('ips', 'r') db = json.load(db) app.g[3] = db gethighscore() setupdb() return app
import xml.etree.ElementTree # If I don't load this here I get error: AttributeError: 'module' object has no attribute 'ElementTree' import rdflib import json import mimetypes # Register RDFLib plugins plugin.register('sparql', query.Processor, 'rdfextras.sparql.processor', 'Processor') plugin.register('sparql', query.Result, 'rdfextras.sparql.query', 'SPARQLQueryResult') plugin.register('sparql', query.Result, 'rdfextras.sparql.query', 'SPARQLQueryResult') app = Flask(__name__) app.REST_API_URL = 'http://localhost/api/resources/' app.g = Graph() app.debug = True app.nss = \ dict( dc=Namespace("http://purl.org/dc/elements/1.1/"), rdf=Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), owl=Namespace("http://www.w3.org/2002/07/owl#"), vin=Namespace("http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#") ) app.g.parse('data/wine.rdf') def serve_file(filepath): with open('./public/' + filepath, "r") as f: (mimetype_prefix, mimetype_suffix) = mimetypes.guess_type(filepath) text = f.read()
import simplejson as json import mongokit #import models #BLUEPRINTS from main.app import main from api.app import api PROD_CONFIG = "config_prod.json" DEV_CONFIG = "config_dev.json" APP_NAME = "gocast" application = Flask(__name__) application.g = g def init_settings(): ''' ''' settings = None abs_path = os.path.abspath(os.path.curdir) if abs_path.find("www") <= 8: abs_path += "/www/" if os.environ.has_key(APP_NAME) and os.environ[APP_NAME] == "production": abs_path += PROD_CONFIG else: print("NB! Database runs with local settings.\n") abs_path += DEV_CONFIG
from curie import uri2curie, curie2uri import os import xml.etree.ElementTree # If I don't load this here I get error: AttributeError: 'module' object has no attribute 'ElementTree' import rdflib import json import mimetypes # Register RDFLib plugins plugin.register('sparql', query.Processor, 'rdfextras.sparql.processor', 'Processor') plugin.register('sparql', query.Result, 'rdfextras.sparql.query', 'SPARQLQueryResult') plugin.register('sparql', query.Result, 'rdfextras.sparql.query', 'SPARQLQueryResult') app = Flask(__name__) app.REST_API_URL = 'http://localhost/api/resources/' app.g = Graph() app.debug = True app.nss = \ dict( dc=Namespace("http://purl.org/dc/elements/1.1/"), rdf=Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), owl=Namespace("http://www.w3.org/2002/07/owl#"), vin=Namespace("http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#") ) app.g.parse('data/wine.rdf') def serve_file(filepath): with open('./public/'+filepath, "r") as f: (mimetype_prefix, mimetype_suffix) = mimetypes.guess_type(filepath) text = f.read() return Response(text, mimetype=mimetype_prefix)
@socketio.on('get-session') def get_session(): emit( 'refresh-session', { 'session': session.get('value', ''), 'user': current_user.id if current_user.is_authenticated else 'anonymous' }) ################################################################################ # Game Play: View Section ################################################################################ app.g = Game() @socketio.on('init') def restart(): app.g = Game() print('\nStart a new game.') emit('next-round', broadcast=True) @app.route('/') def refresh(): is_authenticated = current_user.is_authenticated if not is_authenticated: return render_template('sessions.html',