Integrating dash in XAMPP

Hello!
I need to deploy a python script using dash in a web server in Windows (Not from third parties like Heroku or Wordpress). Particularly, I am using XAMPP, I don’t know if it will be the best option.
The thing is I started with a Hello World example:


index.py:

#! C:/Users/PABLO/Anaconda3/python.exe

print("Content-Type: text/html\n")
print("Hello World!!")

When I type localhost/index.py in my search bar I find:
Hello World!!

So far so good, let’s make it a bit difficult. Now I want to run this other code which is about finding the prime factors of a number, from dash tutorials:


app.py:

#! C:/Users/PABLO/Anaconda3/python.exe

print("Content-Type: text/html\n")
print("<h1>Prime number descomposition</h1>")
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from dash.exceptions import PreventUpdate

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout= html.Div([
       html.P('Enter a composite number to see its prime factors'),
       dcc.Input(id='num', type='number',debounce=True),
       html.P(id='err',style={'color': 'red'}),
       html.P(id='out')
])

@app.callback(
    [Output('out','children'), Output('err','children')],
    [Input('num','value')]
)
def show_factors(num):
    if num is None:
        raise PreventUpdate 
    
   factors=prime_factors(num)
   if len(factors)==1:
          return dash.no_update, '{} is prime!'.format(num) 
    
   return '{} is {}'.format(num, ' * '.join(str(n) for n in factors)), 
def prime_factors(num):
    n, i, out = num, 2, [ ]
    while i * i <= n:
        if n % i == 0:
            n = int(n / i)
            out.append(i)
        else:
            i += 1 if i == 2 else 2
    out.append(n)
    return out

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

But when I put localhost/app.py, the output is:

Prime number descomposition

Running on http://127.0.0.1:8050/ Debugger PIN: 671-393-550 * Serving Flask app “app” (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on

If I go to localhost:8050 I see that the app works well but the idea was to see it all in localhost/app.py like the first file.
Can I make it work well in that direction provided that I don’t want that WARNING to appear?

Thank you so much!

Hello !

Dash is based on Flask so i think it maybe useful to check here it will give you an idea how to use routing to redirect the user to the desired URL, or have your app embedded inside iframe that is written like the Hello World first example you mentioned, if i were you i’ll start from here.

Good luck !

Sorry for the late reply, nut thank you so much, it worked!