How to Setup Python Flask App on Shared Hosting without Sudo

I ❤ Linux

Requirements

Installation

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
export PATH=$PATH:~/.local/bin
pip install --user flask
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
if __name__ == '__main__':
app.run()
{% extends "layout.html" %}
{% block content %}
<div>
<h1>Python 2.6 Web Server</h1>
<h2>Using Flask and Jinja2</h2>
</div>
{% endblock %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}DGtech — Flask App{% endblock %}</title>
{% block head %}
{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
#!/usr/bin/python
import sys
sys.path.insert(0, '<YOUR PATH>')
from wsgiref.handlers import CGIHandler
from myapp import app
CGIHandler().run(app)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ <YOUR PATH>/$1 [L]

--

--

--

Entrepreneur & Full Stack Developer | https://doruk.gezici.me

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Doruk Gezici

Doruk Gezici

Entrepreneur & Full Stack Developer | https://doruk.gezici.me

More from Medium

Nuxt 3 and Django RestFramework works in Docker

Containerize a Python FastApi Into Docker Images

Flask + Celery Ultimate Guide NO BS.

Top Django Development Companies In The UK