Commit 4837dc28 authored by nanahira's avatar nanahira

first

parent 6bcdcc27
Pipeline #12545 failed with stages
in 2 minutes and 10 seconds
.git*
.dockerignore
Dockerfile
__pycache__
__pycache__
stages:
- build
- combine
- deploy
variables:
GIT_DEPTH: "1"
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_TEST_ARM_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-arm
CONTAINER_TEST_X86_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build-x86:
stage: build
tags:
- docker
script:
- TARGET_IMAGE=$CONTAINER_TEST_IMAGE
- docker build --pull -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
deploy_latest:
stage: deploy
tags:
- docker
script:
- TARGET_IMAGE=$CONTAINER_RELEASE_IMAGE
- SOURCE_IMAGE=$CONTAINER_TEST_IMAGE
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
only:
- master
deploy_tag:
stage: deploy
tags:
- docker
script:
- TARGET_IMAGE=$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- SOURCE_IMAGE=$CONTAINER_TEST_IMAGE
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
only:
- tags
FROM python:3.10-slim-bullseye
RUN apt update && apt -y install git build-essential && rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/* /var/log/* /var/cache/apt/archives/*
WORKDIR /app
COPY requirements.txt ./
RUN pip3 install -r ./requirements.txt
COPY . ./
CMD ["./gunicorn_starter.sh"]
import os
import twint
from dacite import from_dict
from flask import Flask, request
app = Flask(__name__)
accessToken = os.environ.get("ACCESS_TOKEN")
allow_list = ["Search", "Profile","Favorites"]
def makeResponse(statusCode, message, data):
return { 'success': statusCode < 400, 'statusCode': statusCode, 'message': message, 'data': data }, statusCode
@app.route("/<methodname>", methods=['POST'])
def encrypt(methodname):
if accessToken and request.headers.get("Authorization") != accessToken:
return makeResponse(403, "Access denied", None)
if methodname not in allow_list:
return makeResponse(404, "Method not found", None)
config_data = request.json
set_proxy(config_data)
tweets = []
c = from_dict(data_class=twint.Config,data=config_data)
c.Store_object = True
c.Store_object_tweets_list = tweets
method = getattr(twint.run, methodname)
method(c)
data = []
for tweets in tweets:
data.append(tweets.__dict__)
return makeResponse(200, "success", data)
def set_proxy(c):
env_list = ["Proxy_host","Proxy_port","Proxy_type","Tor_control_port","Tor_control_password"]
for i in env_list:
e = os.environ.get(i)
if e:
c[i] = e
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
#!/bin/sh
if [ -z "$HOST" ]; then
HOST=0.0.0.0
fi
if [ -z "$PORT" ]; then
PORT=80
fi
gunicorn app:app -w 2 --threads 2 -b $HOST:$PORT
git+https://github.com/letzgobrandon/twint.git@master#egg=twint
flask==2.1.2
dacite==1.6.0
gunicorn
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment