Setup Raspberry pi Flask server using modwsgi

3 views
Skip to first unread message

Jian Wu

unread,
Sep 11, 2021, 12:49:18 PMSep 11
to mod...@googlegroups.com
Hello Graham and community,

I have a Raspberry Pi running on the latest version of Raspbian and I am wondering if I can set it up as a Flask server that can be reached over internet. I have never done a project like this before and I am wondering if this can be done using mod_wsgi? Furthermore is there any documentation or tutorial instructions that you can refer me to?

I have currently set up using this configuration. 

- My router has a static ip and I have ensured that my raspberry pi has a static IP address on 192.168.0.179. 

- Port forwarding is enabled on router using TCP protocol. External port 81 to 192.168.0.179 is routed to internal port 80. Furthermore external port 22 is routed to internal port 22 for 192.168.0.179

My test script looks as below. I hope that when setup correctly I can from any terminal do:

curl http://my_home_static_ip:81/getNewOrderPostBodyStruct and receive the “hello world” message as return

Thanks!

Best regards,
Jian

from flask import Flask
from flask_restful import Resource, Api

app = Flask(__name__)
api = Api(app)

class getNewOrderPostBody(Resource):
def get(self):
return {'data' : "hello world"}
api.add_resource(getNewOrderPostBody, '/getNewOrderPostBodyStruct')

if __name__ == '__main__':
app.run(debug=True)

Graham Dumpleton

unread,
Sep 14, 2021, 9:37:32 PMSep 14
to mod...@googlegroups.com
Technically it could work, but I know of no specific guides on the topic. I would be very careful about opening up ssh access from outside of your home network though.

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/7500F8C9-FA76-420D-A597-0C8F3961409F%40gmail.com.

Reply all
Reply to author
Forward
0 new messages