public networking is not available
nexblu
HOBBYOP

2 years ago

Excuse me sir, I'm trying to deploy a flask application, but the networking for public networking is not created, what is the cause, sir?

11 Replies

2 years ago

have you tried clicking generate domain?


nexblu
HOBBYOP

2 years ago

I am confused why there is no public networking on my flask application


nexblu
HOBBYOP

2 years ago

okey i try


nexblu
HOBBYOP

2 years ago

the result is like this sir

1280206407530057700


nexblu
HOBBYOP

2 years ago

json { "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "NIXPACKS" }, "deploy": { "startCommand": "gunicorn main:app", "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 10 } }

my railway.json


nexblu
HOBBYOP

2 years ago

```py
from flask import Flask
from flaskmongoengine import MongoEngine from routes.license import licenserouter
from routes.user import userrouter from celery import Celery, Task from models import LicenseModel from configs import REDISURL, MONGODBURL, DBNAME

def celeryinitapp(app: Flask) -> Celery:
class FlaskTask(Task):
def call(self, *args: object, *kwargs: object) -> object: with app.app_context(): return self.run(args, **kwargs)

celery_app = Celery(app.name, task_cls=FlaskTask)
celery_app.config_from_object(app.config["CELERY"])
app.extensions["celery"] = celery_app
return celery_app

db = MongoEngine()
app = Flask(name)
app.config["MONGODBSETTINGS"] = { "db": DBNAME,
"host": MONGODBURL, } db.initapp(app)

app.config.frommapping( CELERY=dict( brokerurl=REDISURL, resultbackend=REDISURL, taskignoreresult=True, ), ) celeryapp = celeryinitapp(app)

@celeryapp.task def backgroundtask(data):
import time

time.sleep(data["duration"])
if license := LicenseModel.objects(license=data["license"]).first():
    license.delete()
    return f'successfully deleted {data["license"]}'

@app.afterrequest async def addcors_headers(response):
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE, OPTIONS"
response.headers["Access-Control-Allow-Headers"] = (
"Content-Type, X-API-KEY, X-LICENSE"
)
return response

@app.route("/")
async def home():
return "welcome to auto store api by nexblu store"

app.registerblueprint(licenserouter)
app.registerblueprint(userrouter)

if name == "main":
app.run(debug=True, port=5000)```

my main.py code is like this


2 years ago

keyword: yet


nexblu
HOBBYOP

2 years ago

Sorry sir, what do you mean? I don't understand


imabdulazeez
PRO

2 years ago

Sorry to hijack the thread, just trying to help. Can you try adding PORT to the Variables of the service with the value of 5000. Redeploy and generate a new domain (or add a custom domain) that points to that port

I had this issue with Flask APIs and that did the trick


2 years ago

they don't even have a domain yet, but that's a simple single button press away


nexblu
HOBBYOP

2 years ago

okey thanks its work


Loading...