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
def make_app(): | |
settings = dict( | |
cookie_secret=str(os.urandom(45)), | |
template_path=os.path.join(os.path.dirname(__file__), "templates"), | |
static_path=os.path.join(os.path.dirname(__file__), "static"), | |
default_handler_class=ErrorHandler, | |
default_handler_args=dict(status_code=404) | |
) | |
return tornado.web.Application([ | |
(r"/", StatusHandler), |
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
class StatusHandler(BaseHandler): | |
async def get(self): | |
self.set_status(200) | |
self.write({'message': 'File upload REST API working as expected'}) | |
self.finish() | |
class UploadHandler(BaseHandler): | |
async def get(self): | |
return self.render('uploads.html') |
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
class FileUploadHandler(BaseHandler): | |
""" | |
File upload handler inbehrits the BaseHandler, obtains file data from a POST call | |
""" | |
def post(self): | |
# Retrieve file from the request | |
fileinfo = self.request.files['file'][0] | |
filename = fileinfo['filename'] | |
content_type = fileinfo['content_type'] | |
file_body = fileinfo['body'] |
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
{ Screen Scaling for Device } | |
function GetScreenScale: Single; | |
var | |
ScreenService: IFMXScreenService; | |
begin | |
Result := 1; | |
if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then | |
begin | |
Result := ScreenService.GetScreenScale; | |
end; |
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
{ Where AVP is the TViewport3D or self on a TForm3D } | |
var tmpsp: TPoint3D := ScreenHelper.CalculateScreenPosition(AVP.Context, | |
TPoint3D.Zero, Layer3D1.Scale.Point, Layer3D1.RotationAngle.Point, Layer3D1.Position.Point); | |
Circle1.Position.X := tmpsp.X - Circle1.Width / 2; | |
Circle1.Position.Y := tmpsp.Y - Circle1.Width / 2; | |
{ FIX: TPaintBox offset position } | |
tmpsp.X := tmpsp.X - PaintBox1.Position.X; | |
tmpsp.Y := tmpsp.Y - PaintBox1.Position.Y; | |
tmpr := RectF(tmpsp.X -FSize, tmpsp.Y -FSize, tmpsp.X +FSize, tmpsp.Y +FSize); | |
{ ABMP is a TBitmap } |
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
{ Obtains device scaling } | |
function GetScreenScale: Single; | |
var | |
ScreenService: IFMXScreenService; | |
begin | |
Result := 1; | |
if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then | |
begin | |
Result := ScreenService.GetScreenScale; | |
end; |
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
var tmpsp: TPoint3D := TPoint3D.Zero; | |
// Obtain the screen coordinate by using the WorldToScreen method | |
tmpsp := self.Context.WorldToScreen(TProjection.Camera, Layer3D1.Position.Point); | |
writeln('2D Position: ' + tmpsp.X.ToString + ', ' + tmpsp.Y.ToString); |
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
# A docker-compose must always start by the version tag. | |
# We use '3' because it's the last version at this time. | |
version: '3' | |
# You should know that docker-composes works with services. | |
# 1 service = 1 container. | |
# For example, a service maybe, a server, a client, a database... | |
# We use the keyword 'services' to start to create services. | |
services: | |
# As we said at the beginning, we want to create: a server and a client. |
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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- BEGIN_INCLUDE(manifest) --> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="%package%" | |
android:versionCode="%versionCode%" | |
android:versionName="%versionName%" | |
android:installLocation="%installLocation%"> | |
<uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="33" /> | |
<%uses-permission%> | |
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> |
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
procedure TFrmMain.FormCreate(Sender: TObject); | |
begin | |
{$IFDEF IOS} | |
if NotificationCenter1.AuthorizationStatus <> TAuthorizationStatus.Authorized then begin | |
NotificationCenter1.RequestPermission; | |
end; | |
{$ENDIF} | |
{$IFDEF ANDROID} |
NewerOlder