This is the first time I try to use Flash in front back a WSGI server. And I'm not an expert in python. The problem is : When I launch my wsgi app, the wsgi.py is launched and launch my server.py. The flash application is started. But, it launch only the code in main. So the code before the main of my server.py is not executed (exemple the conf reader in my exemple)
wsgi.py
from server import app
if __name__ == "__main__":
app.run()
server.py
from flask import Flask, request
from flask_caching import Cache
import requests
import configparser
app = Flask(__name__)
config = configparser.ConfigParser()
config.read("config.ini")
cache = Cache(app,config={'CACHE_TYPE': cacheType})
@cache.memoize(5000)
@app.route('/<api>/<type>')
def get_from_splunk(search_query):
print(urlAPI)
r = requests.post(urlAPI, data=search_query, auth=(userSplunk, passwordSplunk), verify=False)
if __name__ == '__main__':
urlAPI = config['config']['urldev']
app.run(debug=True, host= '0.0.0.0', port=5000)
uwsgi.ini
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = project.sock
chmod-socket = 660
vacuum = true
die-on-term = true
I think i forgot something by I can't find what.
When I execute it python : python3.6 server.py. All is ok but with wsgi.py I have an error in execution. urlAPI is empty. I can't understand the entrypoint when it's executed from another file in python.
Thank you for your time.