title: Flask permissions for file writing
body: <p>I'm running a Flask webserver on an EC2 Ubuntu instance.  The purpose is to capture the body of an incoming POST, write it to a file locally, then upload that file to S3.</p>
  
  <p>The code is, basically:</p>
  
  <pre><code>@app.route('/', methods=['GET','POST'])
  @app.route('/index.html', methods=['GET','POST'])
  def index_home():
      data = request.data
      with open('test.json', 'w') as f:
          f.write(data)
  ## Upload the stuff to S3
  </code></pre>
  
  <p>When I run it on the local Flask webserver instance and send a POST with a json body from Postman, it works perfectly.  But on the EC2 instance I'm getting a permissions error (according to the apache error.log) on the 'test.json' file, which results in 500 error on page-load.</p>
  
  <p>I've scoured Google and Stackoverflow (<a href="https://stackoverflow.com/questions/33965370/flask-apache-on-aws-ec2-read-write-failing">Here is a similar question</a>, with no solution) to no avail.  This seems like an easy problem, but I've tried everything and can't seem to get it to work:  I've added my user to the www-data group, I've changed the /var/www folders and files permissions to every combination of root, ubuntu (the default EC2 Ubuntu user) and www-data I could think of, I've straight 777 the directories...nothing seems to work.</p>
  
  <p>Obviously, I'm a bit of a newbie.  Is there a configuration file or something that requires a tweak to get this to work?</p>