R
Railway3mo ago
Eldovyn

public networking is not available

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?
No description
Solution:
have you tried clicking generate domain?
Jump to solution
10 Replies
Percy
Percy3mo ago
Project ID: N/A
Solution
Brody
Brody3mo ago
have you tried clicking generate domain?
Eldovyn
EldovynOP3mo ago
I am confused why there is no public networking on my flask application okey i try
Eldovyn
EldovynOP3mo ago
the result is like this sir
No description
Eldovyn
EldovynOP3mo ago
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "gunicorn main:app",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "gunicorn main:app",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
my railway.json
from flask import Flask
from flask_mongoengine import MongoEngine
from routes.license import license_router
from routes.user import user_router
from celery import Celery, Task
from models import LicenseModel
from configs import REDIS_URL, MONGODB_URL, DB_NAME


def celery_init_app(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["MONGODB_SETTINGS"] = {
"db": DB_NAME,
"host": MONGODB_URL,
}
db.init_app(app)

app.config.from_mapping(
CELERY=dict(
broker_url=REDIS_URL,
result_backend=REDIS_URL,
task_ignore_result=True,
),
)
celery_app = celery_init_app(app)


@celery_app.task
def background_task(data):
import time

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


@app.after_request
async def add_cors_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.register_blueprint(license_router)
app.register_blueprint(user_router)

if __name__ == "__main__":
app.run(debug=True, port=5000)
from flask import Flask
from flask_mongoengine import MongoEngine
from routes.license import license_router
from routes.user import user_router
from celery import Celery, Task
from models import LicenseModel
from configs import REDIS_URL, MONGODB_URL, DB_NAME


def celery_init_app(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["MONGODB_SETTINGS"] = {
"db": DB_NAME,
"host": MONGODB_URL,
}
db.init_app(app)

app.config.from_mapping(
CELERY=dict(
broker_url=REDIS_URL,
result_backend=REDIS_URL,
task_ignore_result=True,
),
)
celery_app = celery_init_app(app)


@celery_app.task
def background_task(data):
import time

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


@app.after_request
async def add_cors_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.register_blueprint(license_router)
app.register_blueprint(user_router)

if __name__ == "__main__":
app.run(debug=True, port=5000)
my main.py code is like this
Brody
Brody3mo ago
keyword: yet
Eldovyn
EldovynOP3mo ago
Sorry sir, what do you mean? I don't understand
A3~
A3~3mo 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
Brody
Brody3mo ago
they don't even have a domain yet, but that's a simple single button press away
Eldovyn
EldovynOP3mo ago
okey thanks its work
Want results from more Discord servers?
Add your server