Create and import (import) library storage when using existing modules such as Flask on GAE in a natural way
When you have created main.py and lib folders in the same hierarchy as app.yaml and want to import various libraries from main.py
root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(root_dir, 'lib'))
Is OK if you write it just before import
sample
#!coding:utf8
import os
import sys
from datetime import date
from google.appengine.ext import ndb
from google.appengine.ext.webapp.util import run_wsgi_app
import csv
import json
import urllib
import datetime
from random import randint
root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(root_dir, 'lib'))
import jinja2
from flask import Flask
from flask import request
from flask import jsonify
from flask import redirect
from flask import render_template
from models import MyModel
Recommended Posts