Giter Site home page Giter Site logo

ericsongxinle / swim4love Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ykps-foobar/swim4love

1.0 0.0 0.0 5.48 MB

Technology support for the Swim For Love Charity Event

License: MIT License

JavaScript 40.79% Python 32.23% CSS 10.77% HTML 16.20%

swim4love's Introduction

Swim For Love

Code for Swim For Love Charity Event.

Installation

Run

git clone https://github.com/YKPS-FooBar/swim4love.git
cd swim4love
pip install -r requirements.txt

in shell to download the code and install prerequisites.

Run

python run.py [-h] [--host HOST] [--port PORT] [--environment {development,production}] [--database DATABASE] [--clean]

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           host address to run Flask (default: localhost)
  --port PORT           port to run Flask (default: 80)
  --environment {development,production}
                        environment for Flask (default: production)
  --database DATABASE   database URI for SQLAlchemy (default: sqlite:///swim4love.db)
  --clean               remove all data from the database (default: False)

Use the --host and --port flags to specify the host and port to run the server on.

The --environment flag specifies whether to run the code in production or development mode.

The --database flag is the URI to connect to for the SQL database. For example, use --database mysql+pymysql://username:password@localhost/swim4love for a MySQL database with a PyMySQL connector, or --database sqlite:///swim4love.db for a local SQLite database. Other SQL servers like PostgreSQL, Oracle, and Microsoft SQL Server are supported.

The code produces database tables storing names of swimmers, volunteers, etc. To clean them, run the code with the --clean flag.

A instance/secrets.py file containing the secret key that signs user session cookies will be automatically generated if not found.

There is a default initial admin with username admin and password equal to the secret key of the app (in instance/secrets.py). When starting the program, use this to create other admins.

Deployment

Example deployment using MySQL on a reverse proxy to port 4000:

python run.py --host localhost --port 4000 --database mysql+pymysql://root:password@localhost/swim4love

The /socket.io directive needs HTTP version 1.1 and the following headers reverse-proxied:

  • Upgrade
  • Connection 'upgrade'
  • Host
  • X-Forwarded-Host
  • X-Forwarded-Proto

For example, in NGINX:

server {
    ...

    location / {
        proxy_pass http://localhost:4000;
    }

    location /socket.io {
        proxy_pass http://localhost:4000;
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Trivia

Eventlet is automatically used. Don't use gunicorn multiple workers since it is not supported by Flask-SocketIO. If using single-worker gunicorn, enable --worker-class eventlet.

Legacy

Pre-2019 code can be found at yu-george/swim4love.

2019 code can be found at commit 0b21f18.

swim4love's People

Contributors

hanwenzhu avatar georgeyjm avatar davidmaamoaix avatar qiyuanbillwu avatar ericsongxinle avatar dependabot[bot] avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.