A simple Python Flask bootstrapper
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.5 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. # Flask Starter Web Application
  2. ## What's included
  3. In this repo is flask web-app skeleton for a basic API or Flask powered website. The stylesheets are Sassy and Bootstrap 4 is included in the Sass libs folder. Everything you need here (except a Sass precompiler) to get started with a Flask App along with deployment instructions for Dreamhost.
  4. [See this project live here](http://flask-skeleton.trevdev.ca/)
  5. ## Requirements
  6. - [Python](https://www.python.org/downloads/) (preferrably Python3)
  7. - [pip package manager](https://pip.pypa.io/en/stable/installing/)
  8. - [Virtualenv](https://virtualenv.pypa.io/en/stable/installation/) for managing virtual environments (installed via pip)
  9. - SASS/SCSS compiler (or not, it's up to you. My SASS files are included in the repo.)
  10. ## Instructions
  11. #### Installation
  12. 1) Clone this repository
  13. ```
  14. git clone ssh://git@git.trevdev.ca:10022/trevdev/flask-starter.git
  15. ```
  16. 2) Enter the flask-starter directory
  17. 3) Setup your virtual environment (virtualenv) and activate your env.
  18. ```
  19. virtualenv env
  20. source ./env/bin/activate
  21. ```
  22. 4) When you see the little (env) indicator on your terminal, install the python package dependancies.
  23. ```
  24. pip install -r requirements.txt
  25. ```
  26. 5) Launch the app and preview it in your browser on localhost:5000.
  27. ```
  28. python launcher.py
  29. ```
  30. 6) Edit/change/develop your site using [Flask + Jinja2](http://flask.pocoo.org/docs/0.12/) (Or whatever other templating you wish to use)
  31. #### Deployment (Dreamhost)
  32. 1) Setup hosting for a domain and ensure you have [passenger enabled](https://help.dreamhost.com/hc/en-us/articles/216385637-How-do-I-enable-Passenger-on-my-domain-) for Python apps.
  33. 2) Use FTP/SFTP to move your project to its destination on Dreamhost (/home/username/example.com). *Be sure to avoid moving any caching or your env*.
  34. 3) Use a secure shell to log in to your dreamhost hosting and run the same steps to setup your pip and virtualenv. If your python is out of date on Dreamhost, you can update it/install your own version.
  35. 4) Configure passenger_wsgi.py to tie-in passenger to your application - specifically the destination of the python file inside ./env/bin/python. You'll need to change the "website" and username in the INTERP string.
  36. ```python
  37. import sys, os
  38. INTERP = '/home/<username>/<website.com>/env/bin/python'
  39. if sys.executable != INTERP:
  40. os.execl(INTERP, INTERP, *sys.argv)
  41. sys.path.append(os.getcwd())
  42. from app import app as application
  43. ```
  44. 5) Wait a few minutes, then visit your website. It should be working. If not, Dreamhost has lots of documentation/support that can help you out. Enjoy!