I have a sanic app which as a server folder, inside that I have server.py along with init.py. Inside init.py I have a one line import *
Here's what server.py looks like:
# server.py #
from sanic import Sanic
from sanic.response import json
class Bot:
def __init__(self):
self.app = Sanic("message-queue")
self.app.add_route(self._post, "/", methods=["POST"])
async def _post(self, request):
data = request.json
data1 = data["data1"]
data2 = data["data2"]
data3 = data["data3"]
def run(self, host="localhost", port=6778):
self.app.run(host, port)
and there is a main file outside of the server folder where I import server.py and run it.
import os
from server import Server
from sanic import Sanic
if __name__ == "__main__":
server = Server()
server.run(host=os.getenv("HOST"), port=int(os.getenv("PORT")))
I accept some POST request via this simple server and print them in the console.It works fine in localhost but in web server If I run it I get webservers localhost address which is not exposed in public. How can I expose it to public? I tried hours and hours, gunicorn, sanic built in server, apache, nginx everything But I failed. I would appreciate any help.