Commit 993f9b5d authored by TOUZE Francois's avatar TOUZE Francois
Browse files

add controller file for Linux

parent d1fddfe0
#!/bin/env python3
from flask import Flask, render_template, jsonify
from flask import request
import os
import json
import urllib.parse
from cython-cpp import pspaclass
from cython-cpp import pspaplots
from flask_cors import CORS
app = Flask(__name__, template_folder='.')
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
curdir = os.getcwd()
print( "current directory => ", curdir)
pkgRoot = curdir.split('pspa')
print( "root directory => ", pkgRoot[0])
upath = os.path.join(pkgRoot[0],'workZone/')
wpath = os.path.join(pkgRoot[0],'pspa/softwares/')
@app.route('/api/importe', methods=['GET', 'POST'])
def importe():
u_bytes= str.encode( upath )
w_bytes= str.encode( wpath )
ptr= pspaclass.PyPspaClass( u_bytes, w_bytes )
x= request.json
print( "/api/importe => ", x['fileName'] )
x_bytes= str.encode( x['fileName'] )
s= ptr.read( x_bytes ).decode('utf-8')
response = {
'import': s
}
return jsonify(response)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment