Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 375b062
Showing
17 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
application: helloworld | ||
version: 1 | ||
runtime: python27 | ||
api_version: 1 | ||
threadsafe: true | ||
|
||
|
||
handlers: | ||
- url: /.* | ||
script: index.app | ||
|
||
|
||
# libraries: | ||
# - name: jinja2 | ||
# version: 2.6 | ||
# - name: setuptools | ||
# version: 0.6c11 | ||
|
||
|
||
# - url: /user/.* | ||
# script: user.app |
Empty file.
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import webapp2 | ||
from google.appengine.ext.webapp import template | ||
|
||
class IndexHandler(webapp2.RequestHandler): | ||
def index(self): | ||
# self.response.headers['Content-Type'] = 'text/plain' | ||
# self.response.write('#oioioi %s' % "aaa") | ||
|
||
template_values = { | ||
'message': "Mensagem para o template.... vindo do IndexHandler..", | ||
} | ||
|
||
|
||
return template_values | ||
|
||
|
||
|
||
# app = webapp2.WSGIApplication([('/', MainPage)], debug=True) | ||
|
||
|
||
|
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import datetime | ||
|
||
from google.appengine.ext import db | ||
|
||
class Greeting(db.Model): | ||
author = db.StringProperty() | ||
content = db.StringProperty(multiline=True) | ||
date = db.DateTimeProperty(auto_now_add=True) | ||
|
||
|
||
|
||
def guestbook_key(guestbook_name=None): | ||
"""Constructs a Datastore key for a Guestbook entity with guestbook_name.""" | ||
return db.Key.from_path('Guestbook', guestbook_name or 'default_guestbook') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import webapp2 | ||
import os | ||
|
||
from google.appengine.ext.webapp import template | ||
|
||
|
||
BASE_CONTROLLER_DIR = "app.controllers" | ||
EXT_ACTION = ".jhtml" | ||
|
||
TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'templates') | ||
|
||
|
||
# | ||
# Ex.: | ||
# /admin --> from app.controllers.admin import index // chama o metodo index | ||
# /admin/cidades --> from app.controllers.admin.cidades import index // chama o metodo index | ||
# /admin/cidades/salvar.jhtml --> from app.controllers.admin.cidades import index // chama o metodo salvar | ||
# | ||
# | ||
def import_from_statement(self): | ||
_from = BASE_CONTROLLER_DIR | ||
_import = "index" | ||
|
||
url_split = self.request.path.split('/') | ||
if not self.request.path == "/": # pacote padrao(index) e action padrao (index) | ||
# _from = _from + "index" | ||
# _import = "index" | ||
|
||
# else: | ||
for s in url_split: | ||
if s: | ||
if not(s.endswith(EXT_ACTION)): | ||
_from += ("." + s) | ||
else: | ||
_import = s.replace(EXT_ACTION, "") | ||
|
||
return "from " + _from + " import " + _import | ||
|
||
|
||
|
||
|
||
|
||
class Handler(webapp2.RequestHandler): | ||
def get(self): | ||
|
||
template_values2 = {} | ||
|
||
# exec_import = import_from() | ||
|
||
path = self.request.path | ||
if path == '/': | ||
exec "from app.controllers import %s" % "index" | ||
exec "template_values2 = index.IndexHandler(self.request, self.response).index()" | ||
|
||
|
||
|
||
template_values2['a'] = self.request.path | ||
template_values2['import_from'] = import_from_statement(self) | ||
|
||
path = os.path.join(TEMPLATE_DIR, 'index.html') | ||
self.response.out.write(template.render(path, template_values2)) | ||
|
||
# else: | ||
# self.response.headers['Content-Type'] = 'text/plain' | ||
# self.response.write('BE Handler %s' % path) | ||
|
||
|
||
|
||
url_map = [ ('/.*', Handler),] | ||
|
||
|
||
app = webapp2.WSGIApplication(url_map, debug=True) | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import webapp2 | ||
import os | ||
import jinja2 | ||
|
||
|
||
# jinja_environment = jinja2.Environment( | ||
# loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) | ||
|
||
# jinja_environment = jinja2.Environment(autoescape = True, | ||
# loader = jinja2.FileSystemLoader(os.path.dirname(__file__), 'templates')) | ||
|
||
|
||
class MainPage(webapp2.RequestHandler): | ||
def get(self): | ||
|
||
|
||
# guestbook_name=self.request.get('guestbook_name') | ||
# greetings_query = Greeting.all().ancestor( | ||
# guestbook_key(guestbook_name)).order('-date') | ||
# greetings = greetings_query.fetch(10) | ||
|
||
# if users.get_current_user(): | ||
# url = users.create_logout_url(self.request.uri) | ||
# url_linktext = 'Logout' | ||
# else: | ||
# url = users.create_login_url(self.request.uri) | ||
# url_linktext = 'Login' | ||
|
||
# template_values = { | ||
# 'greetings': greetings, | ||
# 'url': url, | ||
# 'url_linktext': url_linktext, | ||
# } | ||
|
||
template = jinja_environment.get_template('index.html') | ||
self.response.out.write(template.render(template_values)) | ||
|
||
|
||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
<body> | ||
<b>Referência</b> <br> <a href="https://developers.google.com/appengine/docs/python/gettingstarted/templates">https://developers.google.com/appengine/docs/python/gettingstarted/templates</a> <br> | ||
<pre> | ||
{{message}} | ||
</pre> | ||
<hr> | ||
<b>import_from:</b> <br>{{import_from}} | ||
<hr> | ||
<b>a:</b> <br> {{a}} | ||
<hr> | ||
</body> | ||
</html> |
Binary file not shown.