I have a python Flask server. This server exists to run an open source tool called anki-sync-server (I will refer to this as *the* sync server) that interacts with a local database. When the Flask server receives a request, it kills the sync server, makes changes to the database, then relaunches the sync server.
I'm having an issue where, when the Flask server launches the sync server, my application does not respond to requests that specify a port other than 443, even though the two processes are using ostensibly using ports 81 and 8080 (netstat -tuln shows both ports open and does not list port 443). I can run both the Flask and the sync server individually without issue, but if I have the Flask server launch the sync server as a child process, it seems that the Flask server does not receive any requests. Any requests made to the host url are handled by the child sync server, and any requests to the host url specifying a port other than 443 are handled by neither the flask server nor the sync server. I'm running this project in a cloud provider called repl.it which uses https.
I'm somewhat stuck, but here are some points of note:
- Flask can be specified to use a specific port. If I specify a port, e.g. 80, and
curlto that port, I getcurl: (35) error:0A00010B:SSL routines::wrong version number. This does not occur if I don't specify a port/specify port 443. - anki-sync-server uses http by default.
Here's a simplified version of the relevant code you will find in main.py:
from flask import Flask, request
app = Flask(__name__)
process = subprocess.Popen(['python', '-m', 'anki.syncserver']
@app.route('/')
def index():
return 'test'
I'd appreciate any insight in to this. I think this may have something to do with improperly configured SSL, but I know very little about the subject. You can find the code on github or replit.