def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', get_env()) try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?") from exc execute_from_command_line(sys.argv)
""" WSGI config for restaurant project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application from get_env import get_env os.environ.setdefault('DJANGO_SETTINGS_MODULE', get_env()) application = get_wsgi_application()
from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, String import sys from get_env import get_env import os username = os.getlogin() if username == "ec2-user": # mysqlのDBの設定 DATABASE = 'mysql+mysqldb://{user_name}:{password}@{ip}/{db_name}?charset=utf8mb4'.format( user_name=get_env("MYSQL_USER"), password=get_env("MYSQL_PASS"), ip="localhost", db_name=get_env("DB_NAME"), ) ENGINE = create_engine(DATABASE, encoding="utf-8", echo=False) else: # DATABASE = 'mysql+mysqldb://{user_name}:{password}@{ip}/{db_name}?charset=utf8mb4'.format( # user_name="hyo07", # password="******", # ip="localhost", # db_name="gbvs_radar", # ) # ENGINE = create_engine( # DATABASE, # encoding="utf-8", # echo=False # )
request_handlers = [ (r'/(favicon.ico)', tornado.web.StaticFileHandler, {'path': '../webapp/images'}), (r'/(crossdomain.xml)', tornado.web.StaticFileHandler, {'path': '../webapp'}), (r'/js/(.*)', HubbleStaticFileHandler, {'path': '../webapp/js' }), (r'/css/(.*)', HubbleStaticFileHandler, {'path': '../webapp/css' }), (r'/images/(.*)', HubbleStaticFileHandler, {'path': '../webapp/images' }), (r'/fonts/(.*)', tornado.web.StaticFileHandler, {'path': '../webapp/fonts' }), (r'/lang/(.*)', HubbleStaticFileHandler, {'path': '../webapp/lang' }), (r'/', HubbleIndexHandler), ] application = tornado.web.Application(request_handlers, debug=config.get('App', 'debug_mode'), compress_response=True) certbase = os.path.dirname(os.path.realpath(__file__)) + '/../config/sslcerts/' settings = dict() if get_env() == 'prod': settings['ssl_options'] = { 'certfile': certbase + 'hubbleconnected2015.chained.crt', 'keyfile': certbase + 'hubbleconnected_com.key' } else: settings['ssl_options'] = { 'certfile': certbase + 'hubble_in.crt', 'keyfile': certbase + 'hubble_in.key' } http_server = tornado.httpserver.HTTPServer(application) ssl_server = tornado.httpserver.HTTPServer(application, **settings) if __name__ == "__main__": print "Starting Hubble Tornado server in %s mode..." % get_env()
from requests_oauthlib import OAuth1Session import re from datetime import datetime, timedelta from model import session, Tweet from get_env import get_env CK = get_env("CONSUMER_KEY") CS = get_env("CONSUMER_SECRET") AT = get_env("ACCESS_TOKEN") ATS = get_env("ACCESS_TOKEN_SECRET") twitter = OAuth1Session(CK, CS, AT, ATS) URL = "https://api.twitter.com/1.1/search/tweets.json" params = { "q": "#GBVS対戦募集 exclude:retweets", "lang": "ja", "result_type": "recent", "count": 20, } def cut_text(text): spl_text = text.split("】") return spl_text[-1] def cut_text_2(text, param): text = text.replace("【", "").replace(param, "").replace(":", "").replace( "】", "").replace(" ", "") return text