0

I want a small web page, that once every x seconds, runs a function.(It will display the result of that function)

import datetime
from bottle import Bottle, run

app = Bottle()

@app.route('/')
def hello():
    return datetime.datetime.now()

run(app, host='localhost', port=8080, reloader=True, interval=5)

Right now I've got this. I'm using pythonanywhere for hosting and this won't even run. Error logs state:

FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/uwsgi'

I'm kind lost on this one...

quatro
  • 11
  • 1
  • 1
  • PythonAnywhere dev here. The call to `run` won't work on PythonAnywhere -- it uses uWSGI to host web apps, which runs them inside one or more separate processes. That's how it scales up -- when you get a more expensive hosting plan, it starts up more processes so that you can handle extra traffic. Perhaps you could give more detail about what you're trying to achieve? – Giles Thomas Sep 04 '14 at 11:35
  • Yep, sure. I have a function that runs every x seconds. I want to display for example one.html page if that function returns true, else i want to display two.html. – quatro Sep 04 '14 at 12:56
  • What does the function do? Where should it run? – Giles Thomas Sep 04 '14 at 14:22
  • It checks an api. It returns true or false depending on a certain value. Where should it run? I don't get it, sorry. – quatro Sep 04 '14 at 22:18
  • I guess I'm just confused about the larger issue of what you're trying to achieve. If it's a web app, couldn't you just hit the API on every hit? If you're trying to avoid hammering the API with too many hits, then perhaps you could cache the result? – Giles Thomas Sep 08 '14 at 13:29

1 Answers1

0

not sure exactly what you are doing, but i think you might have more luck if you do this on the browser side instead of the server side.

for example, look at this

Community
  • 1
  • 1
conrad
  • 1,783
  • 14
  • 28