Setup Raspberry pi Flask server using modwsgi

Skip to first unread message

Jian Wu

Sep 11, 2021, 12:49:18 PMSep 11
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 

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

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


Best regards,

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__':

Graham Dumpleton

Sep 14, 2021, 9:37:32 PMSep 14
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
To view this discussion on the web visit

Reply all
Reply to author
0 new messages