Question

Flask Application with wSGI and Nginx not working properly

Posted September 27, 2018 1.5k views
NginxUbuntuPythonApplicationsDeployment

I followed the https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-16-04 tutorial which went smoothly. I am running a simple blockchain type application where you can POST some data to the application and it returns, a transaction record for you.
This worked well on my development server, for as long as I kept it running - I could always send some data and get a response.

I am new to development, so I could have my entire approach wrong, but I assumed that if the script worked fine on the development server, it would also work once deployed.
I have deployed it to https://blockchain.tatiblockchain.co.za
It is not a website so you won’t find anything on the “/” route. But if you go to “/getchain” you should get the current chain stored.

If you go to “/addtransaction” - you should POST a json-object and the fields of that object will be added to the transactions on the server, until they are mined - then they should be added to the chain.

My problem is this - when I call my routes, I get inconsistent results. Sometimes I get a chain back, sometimes a longer one - sometimes I get just a block. The data seems to disappear and re-appear. If the server was not working at all - I should get nothing, but I get wrong data sent back to me, old data or data from the wrong block etc.
It just does not behave the way the development server behaved.

This is an example Below:
try https://blockchain.tatiblockchain.co.za/addtransaction and post

{
"name": "Name Surname"
}

Then call https://blockchain.tatiblockchain.co.za/gettransactions - I am supposed to get that added to the pool. Sometimes I get nothing, sometimes I get it back, sometimes I get old transactions back - I know I have already cleared.

I am using postman to test this.

I have tried - searching for solutions, re-deploying. My dev server works just fine, not the production server.
Should I just leave my application on the development server, I don’t expect to get a lot of requests anyway - because this was just a test project for illustration on another website - I just wanted it hosted online, so I could call it from any computer.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Problem solved, how do I delete this question?

Please, how did you solve your issue. Having the same issue. This time with gunicorn and nginx.

Submit an Answer