Skip to content

Instantly share code, notes, and snippets.

@chaosct
Created October 29, 2015 14:36
Show Gist options
  • Save chaosct/3fcfa909bd2eaf90fac8 to your computer and use it in GitHub Desktop.
Save chaosct/3fcfa909bd2eaf90fac8 to your computer and use it in GitHub Desktop.
simple CORS flask server

Install

virtualenv env
. env/bin/enable
pip install -r requirements.txt
python upload_server.py

Usage

Send the GET request to http://localhost:5000/upload with an argument named path with the path of the file to pass to the script, such as /home/p/Desktop/something.hdf5. That whould be equivalent to GET http://localhost:5000/upload?path=/home/p/Desktop/something.hdf5.

The request will return the link passed by the script or ERROR.

Flask==0.10.1
Flask-Cors==2.1.0
Jinja2==2.8
MarkupSafe==0.23
Unipath==1.1
Werkzeug==0.10.4
argparse==1.2.1
itsdangerous==0.24
six==1.10.0
wsgiref==0.1.2
from flask import Flask, request
from flask.ext.cors import CORS
from unipath import Path
app = Flask(__name__)
CORS(app)
@app.route("/upload")
def hello():
fname = request.args.get("path")
if not fname:
return "ERROR"
fname = Path(fname)
if not fname.exists():
return "ERROR"
#CALL to the python script and get the url
url = "http://repovizz.upf.edu"
return url
if __name__ == "__main__":
app.run()
@slowmountain
Copy link

👍 awesome!
will get back to you as soon as I have some update on the frontend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment