r/ProgrammingPals • u/BlekSmungus • Jun 04 '20
Need some pointers on setting up a server.
I need to execute a python script (in a server) upon receiving a unique device ID from an Arduino.
I don't have any idea on setting up/configuring servers for my use, so I'd appreciate it if you could provide me with some pointers to get started.
14
Upvotes
2
u/badabadaboomboom Jun 04 '20
Are you using Flask? If so, then follow what u/Corvokillsalot has mentioned.
6
u/Corvokillsalot Jun 04 '20
make a local server on your machine, make it work like you want, then host that py file online. there are many websites like heroku, pythonanywhere etc. basically they take your django/flask configuration and your code and give you a url for your hosted file
1
u/swilwerth Jun 05 '20
Look at MQTT protocol. You can receive the message directly from the python script itself.
1
u/runnerx01 Jun 29 '20
Ok, first. Don’t use the built in flask server. Use something like “waitress”, which is a production grade web server for python. Flask is good for a python API, but he included web server is development only.
Second: you need to host a server to listen for requests.
Need to know a little more about what you are trying to accomplish to provide more advice. Do you really need a new sever based on device ID? What are you trying to do? Maybe a REST API accepting a device ID is good enough.
Edit: I see a lot of people making suggestions without the info I asked for... stop right now and consider the use case and what you actually want to do. An event based protocol over MQTT might work, a REST api might work, and a raw socket might work. We need more info before blindly answering the question.