Git Product home page Git Product logo

full-stack-foundations's Introduction

This repository is now DEPRECATED. We are no more maintaining the code here. You can checkout our Full stack Nanodegree for an updated experience.

Full-Stack-Foundations

Solution Code to Full Stack Foundations (ud088)

full-stack-foundations's People

Contributors

adarsh0806 avatar avgn avatar biank88 avatar cristianathompson avatar deepaksandhu avatar hassaanbinaslam avatar ianr01 avatar jperera84 avatar jrrembert avatar karlud avatar lobrown avatar luoto avatar mgruben avatar mvirgo avatar nutjane avatar pmallory avatar sebkouba avatar stevewooding avatar sudkul avatar the-old-one avatar trevstoke avatar wesee avatar yyforyongyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

full-stack-foundations's Issues

Message not printing for webserver.py

Need to convert into bytes , then its printing.

message = ""
message += "Hello!"
#message="Hello World"

        # have to convert the string in to Bytes while writing
         self.wfile.write(bytes(message,"utf8")
        print (message)

implementing login features other than OAuth

Hi Lorenzo,
just wondering, quick query/question ?
I learned a lot with this course and wondering how can I implement login/registration feature other than OAuth and what would be the best package that I can use. please suggest

problem statement/features I am trying to implement in my web app

  • user can register in site (if your don't has his/her social login like google, facebook, msn, etc...)
  • Roles implementation, so that content can be managed based on Roles/admin console/dashboard
  • which package should I use/you guys suggest
    -- Flask-Login ?
    -- Flask-Security ?
    -- Flask-Admin ?

Appreciate it.

webserver.py giving error file not found

Python Version: Python 3.7.5
O.S : Ubuntu 18.04.5

I'm not using vagrant setup. Any help appreciated.

Error :

Error response
Error code: 404
Message: File not found.

Error code explanation: HTTPStatus.NOT_FOUND - Nothing matches the given URI.

Webserver file code:

`from http.server import BaseHTTPRequestHandler,SimpleHTTPRequestHandler, HTTPServer

class webhandler(SimpleHTTPRequestHandler):
      def do_Get(self):
        try:
          if self.path.endswith('/hello'):
            self.send_response(200)
            self.send_header('Content-type','text/html')
            self.end_headers()
            output = ''
            output +=f"<html><body>Hello!</body></html>"
            self.wfile.write(bytes(output,"utf8"))
      
            return 

        except IOError:
              self.send_error(404,"File not found %s" % self.path)
               




def main():
  try:
    port = 8080
    server = HTTPServer(("",port),webhandler)
    print("Web server running on port %s" % port)
    server.serve_forever()
  except KeyboardInterrupt:
      print("^c entered Stopping webserver...")
      server.socket.close()

if  __name__=='__main__':
    main()`

AttributeError from /Lesson-3/20_JSON-Solution/

I got this error

Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "/vagrant/web_server/webbyflask.py", line 18, in restaurantMenuJSON
return item.serialize
AttributeError: 'MenuItem' object has no attribute 'serialize'

this my webbyflask.py

from flask import Flask, render_template, request, url_for, redirect, flash, jsonify
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Base, Restaurant, MenuItem
from flask.templating import render_template
app = Flask(__name__)


engine = create_engine('sqlite:///restaurantmenu.db')
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()

@app.route('/restaurants/<int:restaurant_id>/menu/<int:menu_id>/JSON')
def restaurantMenuJSON(restaurant_id, menu_id):
    item = session.query(MenuItem).filter_by(id = menu_id).one()
    return item.serialize

and this is my database_setup.py

import sys
import os
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine

Base = declarative_base()

class Restaurant(Base):
    __tablename__ = 'restaurant'
    name = Column(String(80), nullable = False)
    id = Column(Integer, primary_key = True)

class MenuItem(Base):
    __tablename__ = 'menu_item'

    name = Column(String(80), nullable = False)
    id = Column(Integer, primary_key = True)
    course = Column(String(250))
    description = Column(String(250))
    price = Column(String(8))
    restaurant_id = Column(Integer, ForeignKey('restaurant.id'))
    restaurant = relationship(Restaurant)

    @property
    def serialize(self):
        return {
            'name': self.name,
            'description': self.description,
            'id': self.id,
            'price': self.price,
            'course': self.course,
        }

Trouble Getting Output from Webserver.py

I have tried doing the Running the Webserver Quiz part using vagrant and virtual box (I'm using Windows 8). But although the file itself runs, the output "Hello" isn't displayed in the browser. I also tried running the file without vagrant but instead I get this

`Error response

Error code: 501

Message: Unsupported method ('GET').

Error code explanation: HTTPStatus.NOT_IMPLEMENTED - Server does not support this operation.`

I don't know what to do, please help. Thank you in advance.

Change item to i in Lesson3/12's project.py file - editmenuitem

Line 75 - 76 in Lesson-3/12_Edit-Menu-Form/project.py the current code is:

        return render_template(
            'editmenuitem.html', restaurant_id=restaurant_id, MenuID=MenuID, item=editedItem)

the variable returned from this function is item. But in the editmenuitem.html, the variable used is i. I think changing item to i can solve the problem.

call method "commit" on line 364

Not a big deal, but you're not calling commit() on line 364, so the Chanterelle toast isn't getting in its own commit. Add the "()".

database_setup.py unable to open database file

Traceback (most recent call last):
File "database_setup.py", line 44, in
Base.metadata.create_all(engine)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 4321, in create_all
ddl.SchemaGenerator, self, checkfirst=checkfirst, tables=tables
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor
with self._optional_conn_ctx_manager(connection) as conn:
File "/usr/lib/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager
with self._contextual_connect() as conn:
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
rec = pool._do_get()
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/impl.py", line 238, in _do_get
return self._create_connection()
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 437, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect
return self.dbapi.connect(*cargs, **cparams)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file

Delete Menu item solution does not work with given html template.

Hi, was working through the course lessons and noticed the following:

Html file is here: https://github.com/lobrown/Full-Stack-Foundations/blob/master/Lesson-3/14_Delete-Menu-Item/deletemenuitem.html

Project.py is here: https://github.com/lobrown/Full-Stack-Foundations/blob/master/Lesson-3/15_Delete-Menu-Item-Solution/project.py#L62

I had to change this line 62 in project.py:
"return render_template('deleteconfirmation.html', item=itemToDelete)"

Changed to match the html file name and variable requirements for given template html.
“return render_template('deletemenuitem.html',restaurant_id=restaurant_id, item=itemToDelete)”

Also I did a search on This repository and there is no files named deleteconfirmation.html yet it is referenced it some of your scripts.

Where is img3.jpg?

The CSS references an img3.jpg which is not in the list of files on github. Please add it.

Errors in the Form portion of the HTML

The code written is listed like this on lines 16, 29 and 52:

'''<form method='POST' enctype='multipart/form-data' action='/hello'><h2>What would you like me to say?</h2><input name="message" type="text" ><input type="submit" value="Submit"> </form>'''

Corrected code should look like this to prevent issues:

"<form method='POST' enctype='multipart/form-data' action='hello'><h2>What would you like me to say?</h2><input name='message' type='text'/><input type='submit' value='Submit'/></form>"

webserver.py not working.

Used 8000 localhost.
Screen Shot 2020-03-17 at 11 11 36 AMScreen Shot 2020-03-17 at 11 11 42 AM

Vagrant is up and running.
Screen Shot 2020-03-17 at 11 14 26 AM

CLI:
Screen Shot 2020-03-17 at 11 11 52 AM

And yet webserver.py is not working.
Please help. Am I missing here something?

/Lesson-3/14_Delete-Menu-Item/deletemenuitem.html (line 15 clarification)

/Lesson-3/14_Delete-Menu-Item/deletemenuitem.html has the following syntax (line 15):
href = "url_for{{('restaurantMenu', restaurant_id = restaurant_id')}}"> Cancel

The above code gave a error but the following change in syntax worked (moving the curly braces):
href = "{{url_for('restaurantMenu', restaurant_id = restaurant_id')}}"> Cancel

Full-Stack_Foundations, editmenuitem.html

It is better to change "placeholder" attribute with value, so that user will already have the initial text, which they can edit. The same with editRestaurant.html.

Errors in Final-Flask-Application

Hi, I noticed some errors in the final code.

In project.py:

  • line 59, when editing a menu item you have the item description being set to the the item name.
  • line 81, you try to render deleteconfirmation.html, which doesn't exist. This should be deletemenuitem.html, or else deletemenuitem.html needs to be renamed

In deletemenuitem.html

  • line 17, you pass 'showMenu' into url_for. 'showMenu' is not defined. This should be restaurantMenu

In editmenuitem.html

  • line 57, you pass 'showRestaurants' into url_for. 'showRestaurants' is not defined. This should be restaurantMenu

problem on code

Kindely 😃 self.wfile.write(message.encode())to write message over connection network must be encoded
not self.wfile.write(message) i have issue and after make encode it's run
self.wfile.write(message.encode()) 👍

L3P11 missing closing mark

In Lesson-3/11_form-requests-and-redirects/project.py, line 36 you missed a closing mark:

Currently:
@app.route('/restaurant/<int:restaurant_id>/<int:menu_id/edit/')
Should be:
@app.route('/restaurant/<int:restaurant_id>/<int:menu_id>/edit/')

Lesson 3.3 Running Your First Flask App " OSError: [Errno 8] Exec format error "

All of the provided code via Udacity has ran smoothly for me until I got to Lesson 3-3 Running Your First Flask Application. I copied and pasted the 'project.py' code directly from Github. Upon running the code via 'python project.py' in the terminal, I get the following error message. I have no clue what it means. Can someone help? Thanks!

vagrant@vagrant:/vagrant/Database_Files$ python project.py

  • Serving Flask app "project" (lazy loading)
  • Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
  • Debug mode: on
  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  • Restarting with stat
    Traceback (most recent call last):
    File "project.py", line 12, in
    app.run(host='0.0.0.0', port=5000)
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 943, in run
    run_simple(host, port, self, **options)
    File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 988, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
    File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())
    File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ, close_fds=False)
    File "/usr/lib/python2.7/subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
    File "/usr/lib/python2.7/subprocess.py", line 711, in init
    errread, errwrite)
    File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
    OSError: [Errno 8] Exec format error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.