Skip to content

Commit

Permalink
build: use python package (setup.py)
Browse files Browse the repository at this point in the history
  • Loading branch information
derlin committed Apr 1, 2022
1 parent e15f2a1 commit c673e28
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.pyc
__pycache__
*.egg
*.egg-info

venv
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.9-alpine3.15

# caching of dependencies
COPY requirements.txt /app/
RUN pip install -r /app/requirements.txt

COPY assets /app/assets
COPY templates /app/templates
COPY rickroller.py server.py /app/
COPY setup.py /app/
COPY rickroll /app/rickroll
RUN pip install -e /app

ENTRYPOINT ["python", "/app/server.py"]
ENTRYPOINT ["python", "-m", "rickroll"]
13 changes: 3 additions & 10 deletions server.py → rickroll/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from flask import Flask, request, render_template
from validators.url import url as urlvalidate
from rickroller import RickRoller
import urllib

from .rickroller import RickRoller

app = Flask(__name__, static_folder='assets')

@app.route('/')
Expand All @@ -14,12 +15,4 @@ def rickroll():

return RickRoller.rickroll(url)

return render_template('index.html')

if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--debug', action='store_true')
args = parser.parse_args()

app.run(host='0.0.0.0', port=8080, debug=args.debug)
return render_template('index.html')
9 changes: 9 additions & 0 deletions rickroll/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import argparse
from . import app

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--debug', action='store_true')
args = parser.parse_args()

app.run(host='0.0.0.0', port=8080, debug=args.debug)
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from setuptools import setup, find_packages
import os, sys

HERE = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(HERE, 'requirements.txt')) as f:
requirements = [line.strip() for line in f if len(line.strip()) and not line.strip().startswith('#')]

setup(
name='rickroll',
packages=find_packages(),
include_package_data=True,
install_requires=requirements,
)

0 comments on commit c673e28

Please sign in to comment.