Example #1
0
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
Example #2
0
File: app.py Project: timoh/GoCast
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
Example #3
0
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)