简体   繁体   中英

How to deploy Flask wsgi application on OPENSHIFT

I have flask app that work perfect on vps with using mod_wsgi. On vps server I configure virtual-host.

I clone my project from github and create wsgi file in repo dir. wsgi:

#!/usr/bin/python

import sys
import os

base_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, base_dir)


def application(environ, start_response):
    from server import app as application
    return application(environ, start_response)

I have next project structure:

server.py
wsgi
--app(folder)
--template(folder)
--static(folder)
--etc(folder)
--bin(folder)

when I curl my site or open pages in browser I got 404 response code and text "error"

in openshift logs/python.log I have only messages with 404 code

How to resolve this or how to deploy flask wsgi app correct.

There is one of my Recent Questions on Deploying Flask in OPENSHIFT
There is not much of help, as noon has given any anwser YET.. But anyway, hope the directory tree and wsgi.py file sample would be of some help..

myflaskaws
├── requirements.txt
├── setup.py
├── static
│   ├── assets
│   │   ├── style.css
│   │   └── images
│   │       ├── no.png
│   │       └── yes.png
│   ├── templates
│   ├── index.html
│   ├── login.html
│   ├── searchlist.html
│   ├── update.html
├── test.py
├── test.pyc
└── wsgi.py`

wsgi.py

#!/usr/bin/python
import os
virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
    execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
    pass

from test import app as application

if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    httpd = make_server('localhost', 8051, application)
    print("Serving at http://localhost:8051/ \n PRESS CTRL+C to Terminate. \n")
    httpd.serve_forever()
    print("Terminated!!")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM