title: Open a text file on a python web application using flask
body: <p>I have a Python application which analyse text data, having purpose to find the topics of the text.</p>
  
  <p>What I need to to do is to make this application a web application.</p>
  
  <p>I set apache, mod_wsgi and flask framework together and I correctly make a simple application which show that everything works.</p>
  
  <p>But when I try to call open() function, I get Internal Server Error.
  I am sure that the path is correct. I try it on a standalone application and there wasn't any problem.</p>
  
  <p>Do you have any clues about what's wrong?</p>
  
  <p>Edit:
  The code that Im trying right now has nothing to do with my application. </p>
  
  <p>This is the main flask file</p>
  
  <pre><code>    #!/usr/bin/python
  
      from flask import Flask,request,render_template
  
  
      import T_testing
  
      app = Flask(__name__)
  
  
      @app.route('/pref',methods = ['GET','POST'])  
      def pref():
          error = None
          return render_template('layout.html',error = error)
  
      @app.route('/running', methods = ['GET','POST'])
      def running ():
        error = None
  
        if request.method == 'POST':  
          dat = request.form['dat']
          alg = request.form['alg']
          dist = request.form['dist']
          threshold = request.form['threshold']
          numoc = request.form['numoc']
  
  
          string = T_testing.run_function(dat,alg,dist,threshold,numoc)
          return string
  
  
      if __name__ == '__main__':
          app.config['TRAP_BAD_REQUEST_ERRORS'] = True
          app.run(host='0.0.0.0',port=5000,debug=True)
  </code></pre>
  
  <p>And this is the T_testing.py</p>
  
  <pre><code>def run_function(st1,st2,st3,st4,st5):
          f = open('/home/christos/public/apps/flaskt/txt_files/textdata.txt','r')
          f.close()
          tablist = [st1,st2,st3,st4,st5]
          strlist = []
          for i in range( 0,len(tablist),1):
              strlist.append(str(tablist[i]))
          return "Choises ARE: "+strlist[0]+" AND "+strlist[1]+" AND "+strlist[2]+" AND "+strlist[3]+" AND "+strlist[4]+" !!!!"
  </code></pre>
  
  <p>(Don't judge the code, I'm just testing..)
  As you can see I get some preferences from layout.html but right now I just print them.</p>
  
  <p>Without the 2 lines about open() and close()  in T_testing, there is no problem. I use Ubuntu by the way. And as I  said the path is working on a standalone python application.</p>
  
  <p>Edit:
  Ok, so I didn't have any solution to my problem. 
  Does anyone had use open() function in a flask web application?
  I want to know if I should continue to try or to find another way to make my web application..</p>
  
  <p>Edit:
  I tried also to create a new file with open('file-name.txt','w'), to check if the path was wrong but again I get error...</p>