Openshift Write and Share via URL
-
26-12-2019 - |
문제
So basically, I'd like to write to a file on Openshift via Python and then have a user able to access the written file via a URL without it being included in the git repository.
So, in essence, let's say I have my script creates a file via:
x = "file.txt"
open(os.path.join(os.getenv("OPENSHIFT_DATA_DIR"), x), 'a').close()
So it creates a blank file with the name file.txt in the root of the OPENSHIFT_DATA_DIR directory, which is the only one that doesn't get impacted by git and is guaranteed not to be overwritten by openshift's procedures.
How would I then provide a link to file.txt? I think this has to deal with .htaccess. Is there another place I should be writing the files?
I've got no idea how to proceed here or if I'm even on the right track so I'd appreciate some help if you can. Thanks!
해결책
I figured out how to do this.
So you gotta use action hooks. I did it by creating...
.openshift/action_hooks/post_deply
#!/bin/bash
if [ ! -d $OPENSHIFT_DATA_DIR/output ]; then
mkdir $OPENSHIFT_DATA_DIR/output
fi
ln -sf $OPENSHIFT_DATA_DIR/output $OPENSHIFT_REPO_DIR/wsgi/static/gifoutput
And then making that file executable (just chmod +x it)
Worked like a charm!