Search Results

Search found 53 results on 3 pages for 'flask'.

Page 1/3 | 1 2 3  | Next Page >

  • "ImportError: No module named flask" - Trouble with nginx + uWSGI + Flask in a virtualenv setup

    - by vjk2005
    I got nginx + uWSGI running on localhost inside a virtualenv with a simple hello world program, but I get this error when I replace the hello world with a simple Flask app: File "./wsgi_configuration_module.py", line 1, in <module> from flask import Flask ImportError: No module named flask unable to load app mountpoint Here's the flask app (wsgi_configuration_module.py): from flask import Flask application = Flask(__name__) @application.route("/") def hello(): return "hello world" if __name__ == "__main__": application.run() uWSGI config (app_conf.xml): <uwsgi> <socket>127.0.0.1:9001</socket> <chdir>/srv/www/labs/application</chdir> <pythonpath>/srv/www</pythonpath> <module>wsgi_configuration_module</module> <callable>application</callable> <no-site>true</no-site> </uwsgi> nginx config: server { listen 80; server_name localhost; access_log /srv/www/labs/logs/access.log; error_log /srv/www/labs/logs/error.log; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:9001; } location /static { root /srv/www/labs/public_html/static/; index index.html index.htm; } } virtualenv stored in ~/virtual_env with Python 2.7 + nginx + uWSGI + Flask installed in a virtualenv called basic. Things I've tried to solve this: set the --home (-H) option to my virtualenv folder ~/virtual_env while running uWSGI. Other info: I have the same setup working outside of a virtualenv. Things go wrong only when I try to replicate the setup inside of a virtualenv. Where have I gone wrong?

    Read the article

  • Flask Admin didn't show all fields

    - by twoface88
    I have model like this: class User(db.Model): __tablename__ = 'users' __table_args__ = {'mysql_engine' : 'InnoDB', 'mysql_charset' : 'utf8'} id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True) email = db.Column(db.String(120), unique=True) _password = db.Column('password', db.String(80)) def __init__(self, username = None, email = None, password = None): self.username = username self.email = email self._set_password(password) def _set_password(self, password): self._password = generate_password_hash(password) def _get_password(self): return self._password def check_password(self, password): return check_password_hash(self._password, password) password = db.synonym("_password", descriptor=property(_get_password, _set_password)) def __repr__(self): return '<User %r>' % self.username I have ModelView: class UserAdmin(sqlamodel.ModelView): searchable_columns = ('username', 'email') excluded_list_columns = ['password'] list_columns = ('username', 'email') form_columns = ('username', 'email', 'password') But no matter what i do, flask admin didn't show password field when i'm editing user info. Is there any way ? Even just to edit hash code. UPDATE: https://github.com/mrjoes/flask-admin/issues/78

    Read the article

  • uWSGI cannot find "application" using Flask and Virtualenv

    - by skyler
    Using uWSGI to serve a simple wsgi app, (a simple "Hello, World") my configuration works, but when I try to run a Flask app, I get this in uWSGI's error logs: current working directory: /opt/python-env/coefficient/lib/python2.6/site-packages writing pidfile to /var/run/uwsgi.pid detected binary path: /opt/uwsgi/uwsgi setuid() to 497 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3 Python version: 2.6.6 (r266:84292, Jun 18 2012, 14:18:47) [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] Set PythonHome to /opt/python-env/coefficient/ *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0xbed3b0 your server socket listen backlog is limited to 100 connections *** Operational MODE: single process *** added /opt/python-env/coefficient/lib/python2.6/site-packages/ to pythonpath. unable to find "application" callable in file /var/www/coefficient/flask.py unable to load app 0 (mountpoint='') (callable not found or import error) *** no app loaded. going in full dynamic mode *** *** uWSGI is running in multiple interpreter mode ***` Note in particular this part of the log: unable to find "application" callable in file /var/www/coefficient/flask.py unable to load app 0 (mountpoint='') (callable not found or import error) **no app loaded. going in full dynamic mode** This is my Flask app: from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello, World, from Flask!" Before I added my Virtualenv's pythonpath to my configuration file, I was getting an ImportError for Flask. I solved this though, I believe (I'm not receiving errors about it anymore) and here is my complete configuration file: uwsgi: #socket: /tmp/uwsgi.sock socket: 127.0.0.1:3031 daemonize: /var/log/uwsgi.log pidfile: /var/run/uwsgi.pid master: true vacuum: true #wsgi-file: /var/www/coefficient/coefficient.py wsgi-file: /var/www/coefficient/flask.py processes: 1 virtualenv: /opt/python-env/coefficient/ pythonpath: /opt/python-env/coefficient/lib/python2.6/site-packages This is how I start uWSGI, from an rc script: /opt/uwsgi/uwsgi --yaml /etc/uwsgi/conf.yaml --uid uwsgi And if I try to view the Flask program in a browser, I get this: **uWSGI Error** Python application not found Any help is appreciated.

    Read the article

  • Email Validation from WTForm using Flask

    - by lost9123193
    I'm following a Flask tutorial from http://code.tutsplus.com/tutorials/intro-to-flask-adding-a-contact-page--net-28982 and am currently stuck on the validation step: The old version had the following: from flask.ext.wtf import Form, TextField, TextAreaField, SubmitField, validators, ValidationError class ContactForm(Form): name = TextField("Name", [validators.Required("Please enter your name.")]) email = TextField("Email", [validators.Required("Please enter your email address."), validators.Email("Please enter your email address.")]) submit = SubmitField("Send") Reading the comments I updated it to this: (replaced validators.Required with InputRequired) (same fields) class ContactForm(Form): name = TextField("Name", validators=[InputRequired('Please enter your name.')]) email = EmailField("Email", validators=[InputRequired("Please enter your email address.")]), validators.Email("Please enter your email address.")]) submit = SubmitField("Send") My only issue is I don't know what to do with the validators.Email. The error message I get is: NameError: name 'validators' is not defined I've looked over the documentation, perhaps I didn't delve deep enough but I can't seem to find an example for email validation.

    Read the article

  • How Flask loads blueprint internaly?

    - by Ignas B.
    I'm just interested how Flask's blueprints gets imported. It still imports the python module at the end of all the stuff done by Flask and if I'm right python does two things when importing: registers the module name in the namespace and then initialize it if needed. So if Flask blueprint is initialized when it gets registered, so all the module then is in memory and if there are lots of blueprints to register, the memory just gets wasted, because in one request basically you use one blueprint. Not a big loss but still... But if it is only registered in the namespace and initialized only when needed (when the real request reaches it), then it make sense to register them all at once (as is the recommended way I understood). This is I guess the case here :) But just wanted to ask and understand a bit deeper.

    Read the article

  • Build error with variables and url_for in Flask

    - by Rob
    Have found one or two people on the interwebs with similar problems, but haven't seen a solution posted anywhere. I'm getting a build error from the code/template below, but can't figure out where the issue is or why it's occurring. It appears that the template isn't recognizing the function, but don't know why this would be occurring. Any help would be greatly appreciated - have been pounding my against the keyboard for two nights now. Function: @app.route('/viewproj/<proj>', methods=['GET','POST']) def viewproj(proj): ... Template Excerpt: {% for project in projects %} <li> <a href="{{ url_for('viewproj', proj=project.project_name) }}"> {{project.project_name}}</a></li> {% else %} No projects {% endfor %} Error log: https://gist.github.com/1684250 EDIT: Also wanted to include that it's not recognizing the variable "proj" when building the URL, so it's just appending the value as a parameter. Here's an example: //myproject/viewproj?projname=what+up Last few lines: [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] File "/srv/www/myproject.com/myproject/templates/layout.html", line 103, in top-level template code, referer: xx://myproject.com/ [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] {% block body %}{% endblock %}, referer: xx://myproject.com/ [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] File "/srv/www/myproject.com/myproject/templates/main.html", line 34, in block "body", referer: xx://myproject.com/ [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] , referer: xx://myproject.com/ [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] File "/usr/lib/python2.7/dist-packages/flask/helpers.py", line 195, in url_for, referer: xx://myproject.com/ [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] return ctx.url_adapter.build(endpoint, values, force_external=external), referer: xx://myproject.com/ [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] File "/usr/lib/pymodules/python2.7/werkzeug/routing.py", line 1409, in build, referer: xx://myproject.com/ [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] raise BuildError(endpoint, values, method), referer: xx://myproject.com/ [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] BuildError: ('viewproj', {'proj': '12th'}, None), referer: xx://myproject.com/

    Read the article

  • Running Flask framework on App Engine: Could not find module app.cgi

    - by Linc
    I'm running this Flask example app on App Engine: http://github.com/gigq/flasktodo You can see on the github page that app.cgi is in the main directory for this project. However, when I run this code I get an error complaining about a missing app.cgi: ERROR 2010-05-01 16:43:47,006 dev_appserver.py:2109] Encountered error loading module "app.cgi": <type 'exceptions.ImportError'>: Could not find module app.cgi Traceback (most recent call last): File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 2096, in LoadTargetModule module_code = import_hook.get_code(module_fullname) File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 1279, in Decorate return func(self, *args, **kwargs) File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 1956, in get_code full_path, search_path, submodule = self.GetModuleInfo(fullname) File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 1279, in Decorate return func(self, *args, **kwargs) File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 1908, in GetModuleInfo submodule, search_path = self.GetParentSearchPath(fullname) File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 1279, in Decorate return func(self, *args, **kwargs) File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 1887, in GetParentSearchPath parent_package = self.GetParentPackage(fullname) File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 1279, in Decorate return func(self, *args, **kwargs) File "/opt/google_appengine/google/appengine/tools/dev_appserver.py", line 1864, in GetParentPackage raise ImportError('Could not find module %s' % fullname) ImportError: Could not find module app.cgi How do I indicate to dev_appserver.py where to look to find it?

    Read the article

  • Temporarily share/deploy a python (flask) application

    - by Jeff
    Goal Temporarily (1 month?) deploy/share a python (flask) web app without expensive/complex hosting. More info I've developed a basic mobile web app for the non-profit I work for. It's written in python and uses flask as its framework. I'd like to share this with other employees and beta testers (<25 people). Ideally, I could get some sort of simple hosting space/service and push regular updates to it while we test and iterate on this app. Think something along the lines of dropbox, which of course would not work for this purpose. We do have a website, and hosting services for it, but I'm concerned about using this resource as our website is mission critical and this app is very much pre-alpha at this point. Options I've researched / considered Self host from local machine/network (slow, unreliable) Purchase hosting space (with limited non-profit resources, I'm concerned this is overkill) Using our current web server / hosting (not appropriate for testing) Thanks very much for your time!

    Read the article

  • How to build an offline web app using Flask?

    - by Rafael Alencar
    I'm prototyping an idea for a website that will use the HTML5 offline application cache for certain purposes. The website will be built with Python and Flask and that's where my main problem comes from: I'm working with those two for the first time, so I'm having a hard time getting the manifest file to work as expected. The issue is that I'm getting 404's from the static files included in the manifest file. The manifest itself seems to be downloaded correctly, but the files that it points to are not. This is what is spit out in the console when loading the page: Creating Application Cache with manifest http://127.0.0.1:5000/static/manifest.appcache offline-app:1 Application Cache Checking event offline-app:1 Application Cache Downloading event offline-app:1 Application Cache Progress event (0 of 2) http://127.0.0.1:5000/style.css offline-app:1 Application Cache Error event: Resource fetch failed (404) http://127.0.0.1:5000/style.css The error is in the last line. When the appcache fails even once, it stops the process completely and the offline cache doesn't work. This is how my files are structured: sandbox offline-app offline-app.py static manifest.appcache script.js style.css templates offline-app.html This is the content of offline-app.py: from flask import Flask, render_template app = Flask(__name__) @app.route('/offline-app') def offline_app(): return render_template('offline-app.html') if __name__ == '__main__': app.run(host='0.0.0.0', debug=True) This is what I have in offline-app.html: <!DOCTYPE html> <html manifest="{{ url_for('static', filename='manifest.appcache') }}"> <head> <title>Offline App Sandbox - main page</title> </head> <body> <h1>Welcome to the main page for the Offline App Sandbox!</h1> <p>Some placeholder text</p> </body> </html> This is my manifest.appcache file: CACHE MANIFEST /style.css /script.js I've tried having the manifest file in all different ways I could think of: CACHE MANIFEST /static/style.css /static/script.js or CACHE MANIFEST /offline-app/static/style.css /offline-app/static/script.js None of these worked. The same error was returned every time. I'm certain the issue here is how the server is serving up the files listed in the manifest. Those files are probably being looked up in the wrong place, I guess. I either should place them somewhere else or I need something different in the cache manifest, but I have no idea what. I couldn't find anything online about having HTML5 offline applications with Flask. Is anyone able to help me out?

    Read the article

  • Do I have partial view/code behind in Flask?

    - by hbrlovehaku
    I'm migrating from C#.NET to Python/Flask. In .NET I have MasterPage, UserControl, PartialView each has its own code behind. e.g. I can save the check login functions in Login.ascx.cs and render the Login.ascx wherever I'd like to. If logged in, it shows the welcome message, else shows the login form. But in Flask I only found {% include 'login.html' %} which include the static html file. How can I implement this design in Flask?

    Read the article

  • flask, lighttpd with fastcgi can't get it to work

    - by kurojishi
    i'm tring to deploy a simple flask script to a lighttpd server with fastcgi. this is the configuration file for lighttpd builded using the flask documentation http://flask.pocoo.org/docs/deploying/fastcgi/#configuring-lighttpd server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect", "mod_rewrite", "mod_fastcgi", ) server.document-root = "/var/www" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" index-file.names = ( "index.php", "index.html", "index.htm", "default.htm", " index.lighttpd.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) var.home_dir = "/var/lib/lighttpd" var.socket_dir = home_dir + "sockets/" ## Use ipv6 if available #include_shell "/usr/share/lighttpd/use-ipv6.pl" dir-listing.encoding = "utf-8" server.dir-listing = "enable" compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain" ) include_shell "/usr/share/lighttpd/create-mime.assign.pl" include_shell "/usr/share/lighttpd/include-conf-enabled.pl" fastcgi.server = ("weibo/callback.fcgi" => (( "socket" => "/tmp/weibocrawler-fcgi.sock", "bin-path" => "/var/www/weibo/callback.fcgi", "check-local" => "disable", "max-procs" => 1 )) ) url.rewrite-once = ( "^(/weibo($|/.*))$" => "$1", "^(/.*)$" => "weibo/callback.fcgi$1" and this is the script i'm tring to run: #!/home/nrl/kuro/weiboenv/bin/python from flup.server.fcgi import WSGIServer from callback import app if __name__ == '__main__': WSGIServer(application, bindAddress='/tmp/weibocrawler-fcgi.sock').run() but i have this error testing the configuration file i get this error: 2013-07-02 17:15:42: (configfile.c.912) source: lighttpd.conf.new line: 52 pos: 1 parser failed somehow near here: weibo/callback.fcgi$1 when i remove the urlrewrite i get these errors in the log even if the daemon start: 2013-07-02 16:25:53: (log.c.166) server started 2013-07-02 16:25:53: (mod_fastcgi.c.1104) the fastcgi-backend fcgi.py failed to start: 2013-07-02 16:25:53: (mod_fastcgi.c.1108) child exited with status 2 fcgi.py 2013-07-02 16:25:53: (mod_fastcgi.c.1111) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version. If this is PHP on Gentoo, add 'fastcgi' to the USE flags. 2013-07-02 16:25:53: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed. 2013-07-02 16:25:53: (server.c.938) Configuration of plugins failed. Going down.

    Read the article

  • How to allow remote connections to Flask?

    - by Ilya Smagin
    Inside the system, running on virtual machine, I can access the running server at 127.0.0.1:5000. Although the 'remote' address of the vm is 192.168.56.101 (ping and ssh work fine), I cannot access the server with 192.168.50.101:5000 neither from the virtual machine nor from the local one. I guess there's something preventing remote connections. Here's /etc/network/interfaces: auto eth1 iface eth1 inet static address 192.168.56.101 netmask 255.255.255.0 ufw is inactive. How do I fix this problem?

    Read the article

  • Why do some Flask session values disappear from the session after closing the browser window, but then reappear later without me adding them?

    - by Ben
    So my understanding of Flask sessions is that I can use it like a dictionary and add values to a session by doing: session['key name'] = 'some value here' And that works fine. On a route I have the client call using AJAX post, I assign a value to the session. And it works fine. I can click on various pages of my site and the value stays in the session. If I close the browser window however, and then go back to my site, the session value I had in there is gone. So that's weird and you would think the problem is the session isn't permanent. I also implemented Flask-Openid and that uses the session to store information and that does persist if I close the browser window and open it back up again. I also checked the cookie after closing the browser window, but before going back to my site, and the cookie is indeed still there. Another odd piece of behaviour (which may be related) is that some values I have written to the session for testing purposes will go away when I access the AJAX post route and assign the correct value. So that is odd, but what is truly weird is that when I then close the browser window and open it up again, and have thus lost the value I was trying to retain, the ones that I lost previously actually return! They aren't being reassigned because there's no code in my Python files to reassign those values. Here is some outputs to helper make it clearer. They are all outputed from a route for a real page, and not the AJAX post route I mentioned above. This is the output after I have assigned the value I want to store in the session. The value key is 'userid' - all the other values are dummy ones I have added in trying to solve this problem. 'userid': 8 will stay in the session as long as I don't close the browser window. I can access other routes and the value will stay there just like it should. ['session.=', <SecureCookieSession {'userid': 8, 'test_variable_num': 102, 'adding using before request': 'hi', '_permanent': True, 'test_variable_text': 'hi!'}>] If I do close the browser window, and go back into the site, but without redoing the AJAX post request, I get this output: ['session.=', <SecureCookieSession {'adding using before request': 'hi', '_permanent': True, 'yo': 'yo'}>] The 'yo' value was not in the first first output. I don't know where it came from. I searched my code for 'yo' and there is no instances of me assigning that value anywhere. I think I may have added it to the session days ago. So it seems like it is persisting, but being hidden when the other values are written. And this last one is me accessing the AJAX post route again, and then going to the page that prints out the keys using debug. Same output as the first output I pasted above, which you would expect, and the 'yo' value is gone again (but it will come back if I close the browser window) ['session.=', <SecureCookieSession {'userid': 8, 'test_variable_num': 102, 'adding using before request': 'hi', '_permanent': True, 'test_variable_text': 'hi!'}>] I tested this in both Chrome and Firefox. So I find this all weird and I am guessing it stems from a misunderstanding of how sessions work. I think they're dictionaries and I can write dictionary values into them and retrieve them days later as long as I set the session to permanent and the cookie doesn't get deleted. Any ideas why this weird behaviour is happening?

    Read the article

  • How safe is it to rely on thirdparty Python libs in a production product?

    - by skyler
    I'm new to Python and come from the write-everything-yourself world of PHP (at least this is how I always approached it). I'm using Flask, WTForms, Jinja2, and I've just discovered Flask-Login which I want to use. My question is about the reliability of using thirdparty libraries for core functionality in a project that is planned to be around for several years. I've installed these libraries (via pip) into a virtualenv environment. What happens if these libraries stop being distributed? Should I back up these libraries (are they eggs)? Can I store these libraries in my project itself, instead of relying on pip to install them in a virtualenv? And should I store these separately? I'm worried that I'll rely on a library for core functionality, and then one day I'll download an incompatible version through pip, or the author or maintainer will stop distributing it and it'll no longer be available. How can I protect against this, and ensure that any thirdparty libraries that I use in my projects will always be available as they are now?

    Read the article

  • Security Pattern to store SSH Keys

    - by Mehdi Sadeghi
    I am writing a simple flask application to submit scientific tasks to remote HPC resources. My application in background talks to remote machines via SSH (because it is widely available on various HPC resources). To be able to maintain this connection in background I need either to use the user's ssh keys on the running machine (when user's have passwordless ssh access to the remote machine) or I have to store user's credentials for the remote machines. I am not sure which path I have to take, should I store remote machine's username/password or should I store user's SSH key pair in database? I want to know what is the correct and safe way to connect to remote servers in background in context of a web application.

    Read the article

  • How To Run Postgres locally

    - by Rohit Rayudu
    I read the Postgres docs for Flask and they said that to run Postgres you should have the following code app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = postgresql://localhost/[YOUR_DB_NAME]' db = SQLAlchemy(app) How do I know my database name? I wrote db as the name - but I got an error sqlalchemy.exc.OperationalError: (OperationalError) FATAL: database "[db]" does not exist Running Heroku with Flask if that helps

    Read the article

  • 500 internal server error on certain page after a few hours

    - by Brian Leach
    I am getting a 500 Internal Server Error on a certain page of my site after a few hours of being up. I restart uWSGI instance with uwsgi --ini /home/metheuser/webapps/ers_portal/ers_portal_uwsgi.ini and it works again for a few hours. The rest of the site seems to be working. When I navigate to my_table, I am directed to the login page. But, I get the 500 error on my table page on login. I followed the instructions here to set up my nginx and uwsgi configs. That is, I have ers_portal_nginx.conf located i my app folder that is symlinked to /etc/nginx/conf.d/. I start my uWSGI "instance" (not sure what exactly to call it) in a Screen instance as mentioned above, with the .ini file located in my app folder My ers_portal_nginx.conf: server { listen 80; server_name www.mydomain.com; location / { try_files $uri @app; } location @app { include uwsgi_params; uwsgi_pass unix:/home/metheuser/webapps/ers_portal/run_web_uwsgi.sock; } } My ers_portal_uwsgi.ini: [uwsgi] #user info uid = metheuser gid = ers_group #application's base folder base = /home/metheuser/webapps/ers_portal #python module to import app = run_web module = %(app) home = %(base)/ers_portal_venv pythonpath = %(base) #socket file's location socket = /home/metheuser/webapps/ers_portal/%n.sock #permissions for the socket file chmod-socket = 666 #uwsgi varible only, does not relate to your flask application callable = app #location of log files logto = /home/metheuser/webapps/ers_portal/logs/%n.log Relevant parts of my views.py data_modification_time = None data = None def reload_data(): global data_modification_time, data, sites, column_names filename = '/home/metheuser/webapps/ers_portal/app/static/' + ec.dd_filename mtime = os.stat(filename).st_mtime if data_modification_time != mtime: data_modification_time = mtime with open(filename) as f: data = pickle.load(f) return data @a bunch of authentication stuff... @app.route('/') @app.route('/index') def index(): return render_template("index.html", title = 'Main',) @app.route('/login', methods = ['GET', 'POST']) def login(): login stuff... @app.route('/my_table') @login_required def my_table(): print 'trying to access data table...' data = reload_data() return render_template("my_table.html", title = "Rundata Viewer", sts = sites, cn = column_names, data = data) # dictionary of data I installed nginx via yum as described here (yesterday) I am using uWSGI installed in my venv via pip I am on CentOS 6 My uwsgi log shows: Wed Jun 11 17:20:01 2014 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 287] during GET /whm-server-status (127.0.0.1) IOError: write error [pid: 9586|app: 0|req: 135/135] 127.0.0.1 () {24 vars in 292 bytes} [Wed Jun 11 17:20:01 2014] GET /whm-server-status => generated 0 bytes in 3 msecs (HTTP/1.0 404) 2 headers in 0 bytes (0 switches on core 0) When its working, the print statement in the views "my_table" route prints into the log file. But not once it stops working. Any ideas?

    Read the article

  • Python Framework for small website

    - by mvid
    I am planning a small, simple website to showcase myself as an engineer. My preferred language is Python and I hope to use it to create my website. My pages will be mostly static, with some database stored posts/links. The site will be simple, but I would like to have freedom in how it operates. I plan on using CSS/JS for the design, so I really just need an easy way to throw a small amount of content around. Some frameworks I have come across: Flask cherry.py Pinax Are there any suggestions? Does anyone have any experience with Python on small/hobby websites?

    Read the article

  • Python in AWS Elastic Beasntalk: Private package dependencies

    - by Adam Matan
    I would like to deploy a Python Flask application on beanstalk. The application depends on external packages (e.g. geopy) and internal packages (e.g. adam_geography). The manual Create a requirements.txt file and place it in the top-level directory of your source bundle. This would probably fetch geopy and its dependencies, but would not fetch adam_geography which is available from a custom repo inside my VPC. How do I specify/upload private, internal Python package dependencies in a Beanstalk application?

    Read the article

  • Pass data in np.dnarray to Highcharts

    - by F.N.B
    I'm working with python 2.7, jinja2, flask and Highcharts. I create two numpy array (x1 and x2, type = numpy.dnarray) and I pass to Highcharts. My problems is, Highcharts don't recognize the commas in the vector. This is my jinja2 code: <script> $(function () { $('#container').highcharts({ series: [{ name: 'Tokyo', data: {{ x1 }} }, { name: 'London', data: {{ x2 }} }] }); }); And this is the error that I look with network chrome dev tools: series: [{ name: 'Tokyo', data: [1 4 5 2 3] }, { name: 'London', data: [3 6 7 4 1] }] I need change the numpy array to python list to pass to Highcharts or there is a better way to do?? Thanks

    Read the article

  • Encoding with url and api

    - by user2950824
    So I have this web app set up and running and it works fine for any username that you request, but when i try http://mrcastelo.pythonanywhere.com/lol/euw/Nazaré, it simply doesnt work - the error that I get on the server is the following: iddata= getJSON(urllolbase+region+urlid+username) #SummonerID UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128) It is annoying me greatly, I've tried some other threads but none of them came to a fix. The api that I am using (www.legendaryapi.com) does accept this because this works. Any idea on how to fix this?

    Read the article

  • Error using paho-mqtt in App Engine Python App

    - by calumb
    I am trying to right a Google Cloud Platform app in python with Flask that makes an MQTT connection. I have included the paho python library by doing pip install paho-mqtt -t libs/. However, when I try to run the app, even if I don't try to connect to MQTT. I get a weird error about IP address checking: RuntimeError: error('illegal IP address string passed to inet_pton',) It seems something in the remote_socket lib is causing a problem. Is this a security issue? Is there someway to disable it? Relevant code: from flask import Flask import paho.mqtt.client as mqtt import logging as logger app = Flask(__name__) # Note: We don't need to call run() since our application is embedded within # the App Engine WSGI application server. #callback to print out connection status def on_connect(mosq, obj, rc): logger.info('on_connect') if rc == 0: logger.info("Connected") mqttc.subscribe('test', 0) else: logger.info(rc) def on_message(mqttc, obj, msg): logger.info(msg.topic+" "+str(msg.qos)+" "+str(msg.payload)) mqttc = mqtt.Client("mqttpy") mqttc.on_message = on_message mqttc.on_connect = on_connect As well as full stack trace: ERROR 2014-06-03 15:14:57,285 wsgi.py:262] Traceback (most recent call last): File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler handler, path, err = LoadObject(self._handler) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 84, in LoadObject obj = __import__(path[0]) File "/Users/cbarnes/code/ignite/tank-demo/appengine-flask-demo/main.py", line 24, in <module> mqttc = mqtt.Client("mqtthtpp") File "/Users/cbarnes/code/ignite/tank-demo/appengine-flask-demo/lib/paho/mqtt/client.py", line 403, in __init__ self._sockpairR, self._sockpairW = _socketpair_compat() File "/Users/cbarnes/code/ignite/tank-demo/appengine-flask-demo/lib/paho/mqtt/client.py", line 255, in _socketpair_compat listensock.bind(("localhost", 0)) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/dist27/socket.py", line 222, in meth return getattr(self._sock,name)(*args) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 668, in bind self._SetProtoFromAddr(request.mutable_proxy_external_ip(), address) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 632, in _SetProtoFromAddr proto.set_packed_address(self._GetPackedAddr(address)) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 627, in _GetPackedAddr AI_NUMERICSERV|AI_PASSIVE): File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 338, in getaddrinfo canonical=(flags & AI_CANONNAME)) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 211, in _Resolve canon, aliases, addresses = _ResolveName(name, families) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 229, in _ResolveName apiproxy_stub_map.MakeSyncCall('remote_socket', 'Resolve', request, reply) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall return stubmap.MakeSyncCall(service, call, request, response) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 328, in MakeSyncCall rpc.CheckSuccess() File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl self.request, self.response) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 200, in MakeSyncCall self._MakeRealSyncCall(service, call, request, response) File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 234, in _MakeRealSyncCall raise pickle.loads(response_pb.exception()) RuntimeError: error('illegal IP address string passed to inet_pton',) INFO 2014-06-03 15:14:57,291 module.py:639] default: "GET / HTTP/1.1" 500 - Thanks!

    Read the article

  • Why won't my service start, and why doesn't upstart output any errors?

    - by Alex Waters
    I am trying to 'start gunicorn' as a service via upstart as user ale. I'm using gunicorn/flask on ubuntu 12.04 w/ init (upstart 1.5) Here is my /etc/init/gunicorn.conf setuid btw setgid flask script export HOME=/home/btw export WORKON_HOME=$HOME/.virtualenvs . $HOME/.virtualenvs/default/bin/activate cd $HOME/flask workon default gunicorn -c gunicorn.py bw:app end script It doesn't output anything other than gunicorn start/running, process 12992. If i then do 'status gunicorn' I get stop/waiting. any ideas on how to debug this? I tried following http://upstart.ubuntu.com/wiki/Debugging but it didn't help. If I do the following as user ale in the app's directory: 1. workon default 2. gunicorn -c gunicorn.py bw:app then Gunicorn runs fine. Here is ~/flask/gunicorn.py: bind = "0.0.0.0:8080" workers = 3 backlog = 2048 worker_class = "gevent" debug = True daemon = False pidfile ="/tmp/gunicorn.pid" log_level = "debug" accesslog = "/var/log/gunicorn/access.log" errorlog = "/var/log/gunicorn/error.log" user = "btw" group = "flask" Also, /var/log/error.log doesn't show anything new when I try to start the Gunicorn service. If I start it manually, it shows that the workers have been loaded, etc. Thanks for any help / suggestions!

    Read the article

  • What is a Web Framework ? How does it compare with LAMP

    - by Nishant
    I started web development in LAMP/WAMP and it was logical to me . There is a Web Server program called Apache which does the networking part of setting up a service on port 80 ( common port ) . If the request is regular HTML it uses the HTTP headers to transport files .And if the request for the file is a PHP one , it has a mod_php with which Apache invokes the PHP interpreter to process the file and it gives back HTML which is again transferred as usual HTML . Now the question is what is a Web Framework ? I came across Python based website creation and there is Flask . What is a flask , how does it compare with LAMP . Further are DJango / Ruby on Rails different from flask ? Can someone answer me and also give some good places to read on these .Thanks for your answers in advance . Further is things like LAMP slower than the common FRAMEWORKS because they claimn easy deplyment fo web apps .

    Read the article

  • REST API rule about tunneling

    - by miku
    Just read this in the REST API Rulebook: GET and POST must not be used to tunnel other request methods. Tunneling refers to any abuse of HTTP that masks or misrepresents a message’s intent and undermines the protocol’s transparency. A REST API must not compromise its design by misusing HTTP’s request methods in an effort to accommodate clients with limited HTTP vocabulary. Always make proper use of the HTTP methods as specified by the rules in this section. [highlights by me] But then a lot of frameworks use tunneling to expose REST interfaces via HTML forms, since <form> knows only about GET and POST. My most recent example is a MethodRewriteMiddleware for flask (submitted by the author of the framework): http://flask.pocoo.org/snippets/38/. Any ways to comply to the "Rule" without hacks or add-ons in web frameworks?

    Read the article

1 2 3  | Next Page >