Comments (10)
On pythonAnywhere i use it like this, you don't actually use run.py on a web server, this is just for development.
import sys
# add your project directory to the sys.path
project_home = u'/home/flaskappbuilder/Flask-AppBuilder-Site'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
activate_this = '/home/flaskappbuilder/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
# import flask app but need to call it "application" for WSGI to work
from app import app as application
from flask-appbuilder.
This should be your wsgi.py file. Please check if this works, then report back.
Thank You.
from flask-appbuilder.
I followed this tutorial:
(https://www.digitalocean.com/community/articles/how-to-deploy-flask-web-applications-using-uwsgi-behind-nginx-on-centos-6-4)
step by step for my fab and it worked fine except for static files ( icons, css, ...) this is my nginx.conf:
worker_processes 1;
events {
worker_connections 1024;
}
http {
sendfile on;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/xml text/css
text/comma-separated-values
text/javascript
application/x-javascript
application/atom+xml;
# Configuration containing list of application servers
upstream uwsgicluster {
server 127.0.0.1:8080;
# server 127.0.0.1:8081;
# ..
# .
}
# Configuration for Nginx
server {
# Running port
listen 80;
# Settings to by-pass for static files
location ^~ /static/ {
# Example:
# root /full/path/to/application/static/file/dir;
root /app/static/;
}
# Serve a static file (ex. favico) outside static dir.
location = /favico.ico {
root /app/favico.ico;
}
# Proxying connections to application servers
location / {
include uwsgi_params;
uwsgi_pass uwsgicluster;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
pasted from that tutorial. how to serve static files? thanks.
from flask-appbuilder.
I have configured it in a different way (no need to change nginx.conf):
First change run.py to this
from app import app
if __name__ == '__main__':
app.run(host='0.0.0.0')
1 - /etc/nginx/sites-available/mysite
server {
listen 0.0.0.0:8090;
server_name _;
location / { try_files $uri @yourapplication; }
location @yourapplication {
include uwsgi_params;
uwsgi_pass unix:/tmp/mysite.sock;
}
}
2 - exec*
ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/mysite
3 - /etc/uwsgi/apps-available/myapp.ini*
[uwsgi]
vhost = true
socket = /tmp/mysite.sock
chmod-socket = 666
venv = /home/dpgaspar/workspace/env
chdir = /home/dpgaspar/workspace/quickhowto
module = run
callable = app
4 - exec
sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/mysite
5 - exec
sudo touch /tmp/mysite.sock
sudo chown www-data:www-data /tmp/mysite.sock
sudo chmod 666 /tmp/mysite.sock
6 - Restart and watch the logs
sudo service nginx restart
sudo service uwsgi restart
sudo tail -f /var/log/uwsgi/app/myapp.log &
sudo tail -f /var/log/nginx/error.log
from flask-appbuilder.
Remember: on the above config, change myapp.ini keys chdir and venv to your F.A.B. app venv and directory.
Hope this helps.
from flask-appbuilder.
I did so ( in FreeBSD 10 ):
1.create a file WSGI.py next to run.py and inside:
from app import app
if name == "main":
app.run(host='127.0.0.1', port='8000')
2.and in nginx.conf:
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8000;
}
3.and finaly issued ( insilde activated virtualenv ):
-> uwsgi --socket 127.0.0.1:8000 -w WSGI:app
then it worked as expected ( without extra conf ).
from flask-appbuilder.
Hi there! I am fighting with this configuration on a Mac and unable to get it working. Any chance of sharing a working recipe? I have other Flask apps working just fine in uWSGI/Nginx, but this one is presenting itself to be quite a challenge. Thanks in advance!
from flask-appbuilder.
I guess I should be more clear. I am able to get my app working on port 8080, but not on port 80. Other Flask apps run just fine on port 80.
from flask-appbuilder.
If you want, I can open a new issue.
from flask-appbuilder.
Never mind, I ran the following uwsgi command in my flask-appbuilder directory: uwsgi -s /tmp/uwsgi.sock -H ./venv/ --chmod-socket=666 --wsgi-file myproject/wsgi.py and all is working on port 80.
from flask-appbuilder.
Related Issues (20)
- it's possible to change the table name for user/role/permission tables? HOT 2
- Unable to retrive more pages from ModelRestApi HOT 1
- Is it possible to add both AUTH_DB and AUTH_OAUTH at a time ? HOT 1
- Order of Lists in Multiview HOT 3
- Make Google OAuth login work for users created using `create-user`
- flask fab create-app returns error HOT 3
- When redefining created and changed by fks to change the custom view, they get nullified HOT 2
- Actual way for Keycloak integration
- Can we add optimistic locking in user land?
- actions on child/related views (multiple childs exist) not working properly HOT 2
- TypeError occured on front-end when using the 'extra_classes=readonly' argument for the Select2Widget HOT 1
- Cannot use anonymous user with LDAP
- user_registration error
- Add support for marshmallow-sqlalchemy 1.0.0
- Support Personal Access Tokens in addition to AUTH_TYPE HOT 1
- [Request] Implement compatibility for Flask 3.0.2
- /static/appbuilder/css/webfonts/fa-regular-400.woff2 file is not found HOT 1
- Bypass Superset keycloak OAUTH login page HOT 1
- Wrong url while getting userinfo from Keycloak HOT 1
- Changed by user column in ab_user table is not updated when user logged in through LDAP HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-appbuilder.