Example #1
0
import os

from decimal import Decimal
from flask import Flask, render_template, request, send_from_directory
from werkzeug.utils import secure_filename

from scripts.varita import process
from scripts.mg_g_muestra import invert_table

app = Flask(__name__)

UPLOAD_FOLDER = "/tmp"
ALLOWED_EXTENSIONS = ["csv"]
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
app.config["RESULT_FOLDER"] = UPLOAD_FOLDER

# app.debug = True


def allowed_file(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in ALLOWED_EXTENSIONS


@app.route("/", methods=["POST", "GET"])
def home():
    if request.method == "GET":
        return render_template("home.html")
    else:
        # POST request
        form = request.form
        f = request.files["csv"]
Example #2
0
# initialize app

_ROOT = path.abspath(path.dirname(__file__))
temp_folder = path.join(_ROOT, "templates")
app = Flask(__name__, template_folder=temp_folder)

with open(path.join(_ROOT, "mapomat.json"), "r") as f:
    # u = pickle._Unpickler(f)
    # u.encoding = 'latin1'
    data = json.load(f)

app.config.update(data)

# Make dir
RESULT_FOLDER = path.join(_ROOT, "results")
app.config["RESULT_FOLDER"] = RESULT_FOLDER

app.config["FILE_LIMIT"] = FILE_LIMIT

if not path.exists(RESULT_FOLDER):
    makedirs(RESULT_FOLDER)


# add db, define db class

app.config["DB_PATH"] = path.join(_ROOT, "mapomat.db")
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///%s" % app.config["DB_PATH"]
# Make annoying warning go away
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db = SQLAlchemy(app)