SOLUTION: MIS 315 San Diego City College Week 3 Business Applications Programming Lab Report

[ad_1]
MIS 315: Interest Applications Programming Lab 4: Interest Web Impression (Canvas Submission Due: 05/15/2020) Vivian Luwen Huangfu Department of Management Notice Systems Fowler College of Business San Diego State University Education & Interest Administration (EBA) Building, April 28, 2020 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 1 / 32 Tefficient of Contents 1 Django 2 HTML 3 Django IPware 4 Passing Postulates From Python Perfect to HTML File 5 Tasks 6 Lab 4 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 2 / 32 Goal HyperText Markup Speech (HTML): to settle the resigned of web pages The most basic erection arrest of web pages Show how to set up and compute a Django impression using repl.it Show how to accompany material Impression Programming Interfaces (APIs) together to engender a new service Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 3 / 32 Django Django is a Python-fixed web framework used for erection web applications of haughty quality Django can aid us forsake repetitive tasks, which fashions the manner of web outgrowth an manageefficient trial and prevents time Design philosophies of Django Loosely coupled (fashion each part of the stack as rebellious as possible) Fast outgrowth (arrange the pay outgrowth of web impressions) Less coding (arrange pay outgrowth) Clean cunning (end up delay a very spotless cunning to fashion outgrowth easy) Don’t Repeat Yourself (DRY) (anything in Django has to be developed in a sole fix, rather than repeating it frequently and frequently) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 4 / 32 Repl.it for Django Repl.it fashions the Django setup manageefficient by providing this judicious set up We’ll be modifying solely a few of these perfects to get the results that we want In the intermediate Repl.it pane, you can see your adjudication In the top-just pane, you can see your web impression, and other people can as-well investigate it if you begin your impression In the bottom-just pane, you can see any faults or other output from your Repl.it webserver Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 5 / 32 Front End vs. Tail End Front end: HTML web pages Back end: python perfects Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 6 / 32 Project Structure myoffice folder: place-of-interest all the python perfects and other folders views.py: this is where you bear administrations that wield solicits and produce counter-arguments settings.py: this is where you accomplish place-of-interest all your contrivance settings urls.py: this is a Python script that accomplish place-of-interest all the URL patterns for your contrivance (basically the incongruous pages of your web impression) static folder: place-of-interest the statues and phraseology perfects templates folder: place-of-interest the html perfects index.html: holds the html notice Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 7 / 32 Tefficient of Contents 1 Django 2 HTML 3 Django IPware 4 Passing Postulates From Python Perfect to HTML File 5 Tasks 6 Lab 4 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 8 / 32 Grimm Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 9 / 32 Grimm (Cont’d) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 10 / 32 Grimm (Cont’d) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 11 / 32 HTML - Using Paragraph A chapter is the basic individual of citation in an HTML instrument A chapter is enclosed in HTML by the p commencement and stagnation tags Browsers visually severed chapters from other citation delay spacing above and adown Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 12 / 32 HTML - Using Heading The leader settles notice encircling the leader of citation, ranging from big font extent to small Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 13 / 32 HTML - Using Fearless and Italic The b tag indicates citation that wants care, love key control in a instrument formless or work indicates in a re-examination, and restores the citation in fearless The i tag indicates citation in an opinion say, such as a expression or phrase in a exotic speech, and is restoreed using italics Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 14 / 32 HTML - Using an Natant List An natant inventory is a assembly of parts, usually inconspicuous and shown using bullets, wrapt by the ul commencement and stagnation tags Each inventory part is wrapt by li commencement and stagnation tags Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 15 / 32 HTML - Using a Table A consultation is an HTML erection wrapt by the consultation commencement and stagnation tags that allows postulates to be unembarrassed in rows and columns A cell is a colony in the consultation at a favoring row and column A consultation row is wrapt by the tr commencement and stagnation tags and contains all the cells delayin a consultation row The th commencement and stagnation tags engender a new consultation cell holding consultation leaderer notice encircling the postulates Usually, the browser accomplish evince the consultation leaderers centered delay a fearless font The td commencement and stagnation tags engender a new consultation cell holding a consultation datum Every cell in a consultation is holded delayin a consultation row Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 16 / 32 HTML - Using a Consultation (Cont’d) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 17 / 32 Tefficient of Contents 1 Django 2 HTML 3 Django IPware 4 Passing Postulates From Python Perfect to HTML File 5 Tasks 6 Lab 4 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 18 / 32 Django IPware Best strive to get client’s IP harangue so that we can divine the location An IP harangue is love a phone compute When you investigate ”google.com”, your computer in-effect contemplates up the the indicate google.com to get a resulting IP harangue that is amalgamateed to one of Google’s servers Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 19 / 32 ip-api ip-api can contemplate up our investigateors’ city and empire using their IP harangue To get the empire and city from an IP harangue we solely want to fashion one web flatter http://ip-api.com/json/130.211.0.120 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 20 / 32 Tefficient of Contents 1 Django 2 HTML 3 Django IPware 4 Passing Postulates From Python Perfect to HTML File 5 Tasks 6 Lab 4 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 21 / 32 Dictionaries Dictionary: place-of-interest a assembly of postulates, mapping of key to appraise Each part consists of a key and a appraise To restore a favoring appraise, use the key associated delay it Format for creating a wordbook: wordbook = {key1:val1, key2:val2} get() administration: get a appraise associated delay restricted key from the dictionary Format: wordbook.get(key) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 22 / 32 Passing Postulates From Python Perfect to HTML File Dictionaries: Key, Appraise Pairs postulates = {”ip harangue key”: ip harangue appraise} views.py: postulates = {”ip harangue key”: ip harangue appraise} index.html: {{ip harangue key}} Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 23 / 32 Tefficient of Contents 1 Django 2 HTML 3 Django IPware 4 Passing Postulates From Python Perfect to HTML File 5 Tasks 6 Lab 4 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 24 / 32 Task 1 Task 1: end all HTML custom (by forthcoming the slides and pdf) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 25 / 32 Task 2 Task 2: evince ip harangue, city, and part indicate in protest.html (by forthcoming the slides and pdf), and evince all other notice of colony in protest.html (the forthcoming is proper an in, yours should be incongruous) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 26 / 32 Task 3 Task 3: go to https://finance.yahoo.com/, picked three stocks, and then ”Historical Data”, engender three consultations in protest.html for stagnation value (Close*) from April 20, 2020-April 24, 2020 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 27 / 32 Task 4 Task 4: engender three figures fixed on three consultations in Task 3 and embed the three figures in protest.html (Hint: using matplotlib to engender the figures) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 28 / 32 Tefficient of Contents 1 Django 2 HTML 3 Django IPware 4 Passing Postulates From Python Perfect to HTML File 5 Tasks 6 Lab 4 Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 29 / 32 Lab 4 Tasks in Summary Task 1: end all HTML custom (by forthcoming the slides and pdf) Finish Task 1 and get screenshot(s) Task 2: evince ip harangue, city, and part indicate in protest.html (by forthcoming the slides and pdf), and evince all other notice of colony in protest.html (the forthcoming is proper an in, yours should be incongruous) Finish Task 2 and get screenshot(s) Task 3: go to https://finance.yahoo.com/, picked three stocks that you are most careful in, and then ”Historical Data”, engender three tables in protest.html for stagnation value (Close*) from April 20, 2020-April 24, 2020 Finish Task 3 and get screenshot(s) Task 4: engender three figures fixed on three consultations in Task 3 and embed the three figures in protest.html (Hint: using matplotlib to engender the figures) Finish Task 4 and get screenshot(s) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 30 / 32 Submission (Revisit) Please suggest to Canvas Lab 4 delay pdf/expression instrument before deadline: Share adjudication in repl.it and then paste repl.it amalgamate (e.g., https://repl.it/@LuwenHuangfu/Lab4) in the instrument (Note: the submission amalgamate can NOT be shown in Canvas, you should go to repl.it directly) Paste the citation for adjudication in the instrument Put all screenshot(s) for adjudication and output in the instrument How to prevent screenshot(s): Option 1: Mac: Shift+Command+4 or Shift+Command+5, Windows: Snipping Tool Option 2: Command + p (Mac), Control + p (Windows), ”Save as PDF” Use the NameTag Lab4 Template.docx as the template and put anything in the template: Name the pdf/expression as NameTag Lab4.pdf/.doc (e.g., Vivian Lab4.pdf) Note: Plase fashion fast screenshots are as lucid and great as possible (Command + ”+” to zoom in) Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 31 / 32 Any Questions? Huangfu, Vivian L. (SDSU) Lab4 EBA, April 28, 2020 32 / 32 MIS315 Lab4 2020 MIS 315: Interest Applications Programming Lab Meeting 4: Interest Web Application Contents MIS 315: Interest Applications Programming ............................................................................................. 1 Lab Meeting 4: Interest Web Application..................................................................................................... 1 1. Create Django contrivance via Repl.it .......................................................................................................... 3 1) Go to the classroom of Repl.it. Hurry the “my repls” pin on the loftier just cavity. ......... 3 2) Then click on “+ new repl” on the loftier just cavity........................................................... 3 3) Search for “Django” from the inventory of profitefficient programming speechs and frameworks. .... 3 4) Indicate your repl as “Lab4”. Repl.it accomplish go aleader and set up a ample Django contrivance for you delay some defaults. Click on “run” pin. .................................................................................. 3 5) 2. It should contemplate very resembling to the page adown. ...................................................................... 5 Changing our static resigned .................................................................................................................. 5 1) Right click on “mysite” and “Add perfect”, and indicate it as “views.py”...................................... 5 2) Change the adjudication in “urls.py”. .............................................................................................. 6 3) Change the adjudication in “settings.py”. ........................................................................................ 6 4) Click on “restart” and you should see the figures as follows. ............................................... 7 3. HTML Basic Elements ......................................................................................................................... 7 1) Just click on “mysite” and “Add folder”. Indicate the folder as “templates”. Just click on “templates” and “Add perfect”. Indicate the perfect as “index.html”. ......................................................... 8 2) Change “views.py”: ............................................................................................................. 8 3) Click on “restart” and you should see: ................................................................................. 8 4) Change “index.html”: .......................................................................................................... 9 5) You can as-well hurry the pop-out pin to the just of the URL bar to known solely the resulting web page that we’re erection. You can portion-out the URL delay anyone and they’ll be efficient to see your weboffice already! ........................................................................................................................ 14 4. Passing postulates from python perfect to html.................................................................................................. 14 1) Install ipware impute. ...................................................................................................... 14 2) Type in “ipware” and you accomplish confront “Django-ipware”, click on it. ...................................... 14 3) Click on the “+” office as adown...................................................................................... 15 4) Go tail to “Files”. Change “views.py”: ............................................................................ 15 ................................................................................................................................................................... 15 5) Change “templates/index.html”: ........................................................................................ 16 1 | Page MIS315 Lab4 2020 6) You should evince all the notice in the protest.html (We bear already evinceed two pieces of notice: city, partName)................................................................................... 17 5. Display statue in html. ....................................................................................................................... 18 1) Downimpute sdsu.jpg from Canvas. ...................................................................................... 18 2) Just click “mysite” and “Add folder”. Indicate the folder as “static” and put “sdsu.jpg” in the folder. ....................................................................................................................................... 18 3) Go to “templates/index.html”. Add two lines of adjudication (highlighted adown). ........................ 18 2 | Page MIS315 Lab4 2020 The appearance of this lab meeting is to aid you get begined delay interest web impressions. 1. Engender Django contrivance via Repl.it 1) Go to the classroom of Repl.it. Hurry the “my repls” pin on the loftier just corner. 2) Then click on “+ new repl” on the loftier just cavity. 3) Search for “Django” from the inventory of profitefficient programming speechs and frameworks. 4) Indicate your repl as “Lab4”. Repl.it accomplish go aleader and set up a ample Django contrivance for you delay some defaults. Click on “run” pin. 3 | Page MIS315 Lab4 2020 4 | Page MIS315 Lab4 2020 5) It should contemplate very resembling to the page adown. 2. Changing our static resigned 1) Just click on “mysite” and “Add perfect”, and indicate it as “views.py”. from django.http meaning HttpResponse def protest(request): produce HttpResponse("Hello World") 5 | Page MIS315 Lab4 2020 2) Change the adjudication in “urls.py”. from . meaning views urlpatterns = [ path('admin/', admin.site.urls), path('', views.index, indicate='index'), ] 3) Change the adjudication in “settings.py”. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mysite' ] 6 | Page MIS315 Lab4 2020 4) Click on “restart” and you should see the figures as follows. 3. HTML Basic Elements 7 | Page MIS315 Lab4 2020 1) Just click on “mysite” and “Add folder”. Indicate the folder as “templates”. Right click on “templates” and “Add perfect”. Indicate the perfect as “index.html”. The dolphin Hello HTML 2) Change “views.py”: from django.http meaning HttpResponse from django.shortcuts meaning restore def protest(request): #produce HttpResponse("Hello World") produce restore(request, "index.html") 3) Click on “restart” and you should see: 8 | Page MIS315 Lab4 2020 4) Change “index.html”: a. Using p(chapter restoreing) parts The dolphin

Dolphins are mammals, not fish.

They feed in water but mutter through a blowhole.

9 | Page MIS315 Lab4 2020 b. Using h(headings) The dolphin

Heading raze 2

Heading raze 3

Heading raze 4

Heading raze 5
Heading raze 6
c. Using b(bold) and i(italic) 10 | Page MIS315 Lab4 2020 Dolphins

Whales are not fish.

d. Using an ul(natant inventory) Unordered List

European countries

  • Germany
  • United Kingdom
  • France
  • Greece
11 | Page MIS315 Lab4 2020 e. Using a lowly consultation You use the consultation part to engender a consultation. A consultation part may hold any compute of rows, each created using the tr part. A tr part that holds a leadering may hold any compute of th parts. A tr part that holds usual rows may hold any compute of td parts. Tech Stocks

Favorite Tech Stock Prices

Symbol Company Closing value AAPL Apple Inc. $109.14 GOOG Google Inc. $518.63 12 | Page MIS315 Lab4 2020 NFLX Netflix Inc. $454.17 TSLA Tesla Motors Inc. $205.98 13 | Page MIS315 Lab4 2020 5) You can as-well hurry the pop-out pin to the just of the URL bar to known solely the resulting web page that we’re erection. You can portion-out the URL delay anyone and they’ll be efficient to see your weboffice already! 4. Passing postulates from python perfect to html 1) Install ipware impute. 2) Type in “ipware” and you accomplish confront “Django-ipware”, click on it. 14 | Page MIS315 Lab4 2020 3) Click on the “+” office as adown. 4) Go tail to “Files”. Change “views.py”: 15 | Page MIS315 Lab4 2020 from django.http meaning HttpResponse meaning solicits from django.shortcuts meaning restore from ipware meaning get_client_ip def protest(request): # produce HttpResponse("Hello, globe.") ip_address_appraise = get_client_ip(request)[0] print("ip_address_value", ip_address_value) counter-argument = solicits.get("http://ipapi.com/json/{}".format(ip_address_value)) colony = counter-argument.json() regionName_appraise = colony.get("regionName") city_appraise = colony.get("city") postulates = {"ip_address_key": ip_address_value, "regionName_key": partName_value} "city_key": produce restore(request, 'index.html', concitation = postulates) 5) Change “templates/index.html”: Dolphins

{{ip_address_key}}

{{city_key}}, {{regionName_key}}

...
Purchase exculpation to see ample attachment

[ad_2]
Source amalgamate