web.py webpage running at host location
Posted: Sat Oct 14, 2017 1:36 pm
is it possible to have web.py open its own output?
for example
python script...
html code, running from python_file/static (create a folder called static for this to go in, file is named index.html)
to run this i currently would go to localhost:8080 on the computer it is running from, but is it possible to have the webpage opened just by running the python script? could there be a possibility where localhost wouldnt work and it would need to find its own IP?
for example
python script...
Code: Select all
import web
urls = (
'/', 'Index'
)
app = web.application(urls, globals())
render = web.template.render('static/')
class Index(object):
def GET(self):
msg = "Hello World"
return render.index(msg=msg)
if __name__ == "__main__":
app.run()
Code: Select all
$def with (msg)
<!DOCTYPE html>
<html lang="en">
<body>
<header>
<h1>$msg</h1>
</header>
</body>
</html>