Skip to content

LambdaVex/flask-playground

Repository files navigation

flask-playground

  • install flask:

     python -m pip install flask 
  • running flask app (only for development purposes):

     $ export FLASK_APP=flashcards.py 
     $ export FLASK_ENV=development 
     $ flask run
     # or
     $ python –m flask run 

    -For windows, use set instead of export-

  • overview of the app (which methods and functionaliy are available):

    • go to the direcroy and start python in the terminal (IDE terminal or Standalone terminal)
     $ python
     $ import flashcards
     $ flashcards.app.url_map
  • usual communication model in MVC or MTV (Model-Template-View): grafik

  • running flask app without using a package (production environment):

    • download the code on the server
     $ pip3 install -r requirements.txt
     $ sudo apt install gunicorn3
     $ gunicorn3 -D flashcards:app
     # now the deamon is running on port 8000
     # we need to use nginx tp have a reverse proxy
     $ cd /etc/nginx/sites-available/
     # get settings from : https://gunicorn.org/#deployment
     # change server_name and access_log 
     $ sudo nano default 
       server {
           listen 80;
           server_name example.org;
           access_log  /var/log/nginx/example.log;
    
           location / {
               proxy_pass http://127.0.0.1:8000;
               proxy_set_header Host $host;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              }
      }
     
     $ sudo service nginx restart  

About

A playground for python flask

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published