2 Creating a Custom Tiny Web DB Service
靜宜大學資管系 楊子青 2 Creating a Custom Tiny. Web. DB Service • http: //beta. appinventor. mit. edu/learn/reference/other/ tinywebdb. html – Tiny. Web. DB is an App Inventor component that allows you to store data persistently in a database on the web. – By default, the Tiny. Web. DB component stores data on a test service provided by App Inventor, http: //appinvtinywebdb. appspot. com/. • This service is helpful for testing, but it is shared by all App Inventor users, and it has a limit of 1000 entries. If you use it, your data will be overwritten eventually. – For most apps you write, you'll want to create a custom web service that isn't shared with other App Inventor apps and programmers.
靜宜大學資管系 楊子青 3 To create your own web service • Follow these instructions: – Download App Engine for Python at http: //code. google. com/appengine/. (之前需先下載Python) • After installing it, run the Google. App. Engine. Launcher by clicking its icon. – Download this sample code and Unzip the downloaded zip file. • It is a zip file containg the source code for your custom tinywebdb web service. (檔案有問題,改找appinventordb. zip) – In the Google. App. Engine. Launcher, choose File | Add Existing Application. • Browse to set the Path you just unzipped. • Then click the Run button. This will launch a test web service that runs on your local machine. – You can test the service by opening a browser and entering “localhost: 8080” as the URL. You‘ll see the web page interface to your web service. (如果瀏覽器無法顯示,也沒有關係)
靜宜大學資管系 楊子青 4 To create your own web service (Cont. ) • Follow these instructions: – Your app is not yet on the web. You need to upload it to Google's App Engine servers. • In the Google. App. Engine. Launcher, choose Dashboard. – Enter your Google account information and you'll be taken to an App Engine dashboard. • Choose Create an Application. – You'll need to specify a globally unique Application Identifier. – Provide a name to your app and click Create Application to submit. • Edit the file app. yaml. – Modify the first line so that the application matches the application identifier • In Google. App. Engine. Launcher, choose Deploy and follow the steps. – Test to see if your app is running on the web. In a browser, enter myapp. appspot. com, only substitute your identifier for "myapp". • It’s on the web and you can access it from your App Inventor for Android app.
靜宜大學資管系 楊子青 5 To create your own web service (Cont. ) • Follow these instructions: – Your App Inventor apps can store and retrieve data using your new service. Just do the following: • Drag in a Tiny. Web. DB component into the Component Designer. • Modify the Service. URL property from the default http: //appinvtinywebdb. appspot. com/ to your web service. • Any Store. Value operations (blocks) will store data at your service, and any Get. Value operations will retrieve from your service.
- Slides: 5