Git Product home page Git Product logo

python_www_with_uwsgi_and_flask's Introduction

Make dynamic WWW site with Python using uWSGI and Flask

How to run using alwaysdata.com

It's possible using 100MB free plan

In https://admin.alwaysdata.com/site choose 'Modify' option at your new site

In 'Addresses' tab:

  • type '<username>.alwaysdata.net'

In 'Configuration':

  • under 'Type' choose 'Python WSGI'
  • under 'Application path' choose '/www/wsgi.py'
  • under 'Working directory' choose '/www/'
  • under 'virtualenv directory' choose '/www/.venv/'

In 'Advanced configuration':

  • under 'uWSGI additional settings' write 'py-autoreload = 1'

Keep in mind that it auto-reloads changes in all files only when any .py file changed, so it's not ideal, but I didn't manage 'hot-restart = true' to work. It's good enough for now.

Click 'Submit' in bottom right corner.
In https://admin.alwaysdata.com/ssh/ choose 'Modify' option.
and under 'Password' choose some password.
Enable 'Enable password-based login' checkbox.
Click 'Submit' in bottom right corner.
Go back to https://admin.alwaysdata.com/ssh/ and click 'on the Web'
Log in using username (which is displayed in link as https://ssh-<username>.alwaysdata.net/)
and newly created password.
Now you need to copy setup.sh file into ~ directory.
You can do this using FileZill'a FTP, SSH or WebDAV
but probably to easiest way is to just paste file with its content by typing:

echo -e "echo \"Disk usage at the beginning:\"\ndu -sh *\nrm -r www\necho \"Disk usage after rm -r www:\"\ndu -sh *\nmkdir www\ncd www\ncat <<EOF >wsgi.py\nfrom flask_app import app as application\nEOF\ncat <<EOF >flask_app.py\nfrom flask import Flask\nfrom sys import version\n\napp = Flask(__name__)\n\[email protected](\"/\")\ndef flask_app():\n    return \"Hello uWSGI from python version: <br>\" + version\nEOF\npython -m venv .venv\n. .venv/bin/activate\npip install Flask\n# pip install pyuwsgi\necho \"\'pip install pyuwsgi\' was not executed since on alwaysdata it is preinstalled.\"\ncd ..\necho \"Check if don't need to install these; maybe they're preinstalled:\"\necho \"Disk usage after setup:\"\ndu -sh *" > setup.sh

Then execute first commands to be able to run setup.sh and then run it

chmod +x setup.sh
./setup.sh

Now in https://admin.alwaysdata.com/site choose 'Restart' option at your new site to ensure that changes were saved. Now by going to https://<username>.alwaysdata.net/ you should see basic site with default text:
Hello uWSGI from python version:
3.12.0 (main, Dec 5 2023, 07:53:35) [GCC 8.3.0]

If everything works, you can update files inside www directory.

python_www_with_uwsgi_and_flask's People

Contributors

hpamula avatar

Watchers

 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.