study Posted April 10, 2017 Posted April 10, 2017 Hi... please help me...I'm just have one of problem.I want to use python but i don't know to setting to flask.i did searching google, file: public-html/cgi-bin/cgi.cgi #!/usr/bin/python from wsgiref.handlers import CGIHandlerfrom views import appimport osimport cgitb; cgitb.enable() os.environ['SERVER_NAME'] = '127.0.0.1'os.environ['SERVER_PORT'] = '5000'os.environ['REQUEST_METHOD'] = 'GET'os.environ['PATH_INFO'] = ""CGIHandler().run(app) file: views.py from flask import Flaskapp = Flask(__name__) @app.route("/")def hello(): return "This is Hello World!\n" if __name__ == "__main__": app.run() file: .htaccess RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ /home/USERNAME/public_html/cgi-bin/cgi.cgi/$1 [L] ...i had connect to host on webit's just show me that text '/Index' also i was uploaded files that i made to python files and html files in templates folder but it is not working. My english is so bad...sorry. please help me ㅠㅠㅠㅠ
wolstech Posted April 10, 2017 Posted April 10, 2017 You're the second one to ask about Flask. Flask is currently not supported. Is there a reason you can't use Django or plain python/CGI?
dulos Posted April 26, 2017 Posted April 26, 2017 It's a pity! I am the 3-rd one here who likes to play with flask :-( So we have to migrate to another sandbox, maybe http://pythonanywhere.comAnd what with bottle?
Krydos Posted April 27, 2017 Posted April 27, 2017 From what I understand flask is used primarily on home computers where you might not have access to a mature tested apache server to test your python web scripts in a fully python environment. As soon as someone explains why they need flask to do something that django/apache cgi can't already do I'll be listening. Apache configuration can be daunting and complex. I get it. I'm the one that configures it, but the main advantage to flask is being able to run a janky webserver super easily by simply running the command ./runserver, but you really don't need that if you have a real http/https server.
robertoo Posted May 27, 2017 Posted May 27, 2017 Hi, thanks for a great hosting site, I'd also would like to be able to play with Flask, the reason being that it's easier to use as a simple Rest Api framework, I don't need/want a full ORM, nor database models, nor migration, nor user authentication, just a plain old simple rest api.
Krydos Posted May 28, 2017 Posted May 28, 2017 (edited) Alright! Create a folder in public_html called flask/home/username/public_html/flask/ In that folder create a .htaccess file: /home/username/public_html/flask/.htaccessRewriteEngine On RewriteBase / RewriteRule ^(media/.*)$ - [L] RewriteRule ^(admin_media/.*)$ - [L] RewriteRule ^(flask\.wsgi/.*)$ - [L] RewriteRule ^(.*)$ flask/flask.wsgi/$1 [QSA,PT,L] Create a file named flask.wsgiimport os, sys # edit your username below sys.path.append("/home/username/public_html/flask"); sys.path.insert(0, os.path.dirname(__file__)) from myapp import app as application # make the secret code a little better application.secret_key = 'secret' Create a python script named myapp.pyimport sys from flask import Flask, __version__ app = Flask(__name__) application = app @app.route("/") def hello(): return """ HelioHost rules!<br><br> <a href="/flask/python/version/">Python version</a><br> <a href="/flask/flask/version/">Flask version</a> """ @app.route("/python/version/") def p_version(): return "Python version %s" % sys.version @app.route("/flask/version/") def f_version(): return "Flask version %s" % __version__ if __name__ == "__main__": app.run() Here is the working example: https://krydos.heliohost.org/flask/ This will only work on Tommy at the moment. Feel free to play around with it and let me know if you have any issues. If everything is working I'll see about writing up a wiki and making a news post about HelioHost now supporting flask. Edited August 12, 2017 by Krydos Specified location of .htaccess 1
jkc Posted August 15, 2017 Posted August 15, 2017 Hi Krydos,I'm just a new user and I'm also interested in using Flask. I activated my account last night and was dropped to Johnny. If I remember right, Tommy was marked as full. So my question is, if there is any chance to use Flask on Johnny in the nearer future ? Thanks for your advice Jürgen
Krydos Posted August 16, 2017 Posted August 16, 2017 Flask is only available on Tommy. Ruby on Rails and Flask/Django don't play well together so we have to choose one or the other basically. We choose RoR on Johnny and Flask/Django on Tommy. If you need RoR you have to pick Johnny, and if you need Flask you have to pick Tommy. Python 3.6 and cgi are available on both servers. Once we get Ricky online in the next month or so we will have Flask/Django on that server as well. http://wiki.helionet.org/Moving_your_account
pepwitch Posted December 1, 2017 Posted December 1, 2017 Thanks for doing this, Krydos - another new user here with a simple Rest Api. Really impressed that you took the effort to implement Flask for Python; I'll follow the steps above and see how I go on Tommy. Cheers.
scottgigante Posted March 13, 2020 Posted March 13, 2020 (edited) Sorry to revive a dead thread but I've copied those files line for line (replacing `username` with my username) and I get a 404 at https://yalefwd.heliohost.org/flask/. Not really sure how to troubleshoot. [Fri Mar 13 21:45:28.922007 2020] [wsgi:error] [pid 14249] [client 38.126.101.151:36244] Target WSGI script not found or unable to stat: /home/yalefwd/public_html/flask/flask.wsgi Edited March 13, 2020 by scottgigante
Recommended Posts