Skip to content
Snippets Groups Projects
Commit 0676be3f authored by Ziyan Lu's avatar Ziyan Lu
Browse files
parents 7086f2f6 c2439806
No related branches found
No related tags found
No related merge requests found
# CMT313_Week5
# Flask - Labs
This repository covers exercises in Flask labs.
Click on the relevant tag to access a snapshot of the state of the Blog project at a particular point of the lab tasks completion.
## Getting started
## Contents:
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
| Lab | Functionality | Git Tag |
|------|---------------------------|---------|
| 1.1 | Basic "Hello World!" page | [part 1.1](https://git.cardiff.ac.uk/scmne/flask-labs/-/tree/part_1.1) |
| 1.2 | Basic templating, routes, navigation and styling | [part 1.2](https://git.cardiff.ac.uk/scmne/flask-labs/-/tree/part_1.2) |
| 1.3 | Reorganising the project for Blogging Website | [part 1.3](https://git.cardiff.ac.uk/scmne/flask-labs/-/tree/part_1.3) |
| 2.1 | Blogging Website: database implementation, dynamic home page| [part 2.1](https://git.cardiff.ac.uk/scmne/flask-labs/-/tree/part_2.1) |
| 2.2 | Blogging Website: individual post pages| [part 2.2](https://git.cardiff.ac.uk/scmne/flask-labs/-/tree/part_2.2) |
| 3.1 | Blogging Website: user accounts | [part 3.1](https://git.cardiff.ac.uk/scmne/flask-labs/-/tree/part_3.1) |
| 3.2 | Blogging Website: validation | [part 3.2](https://git.cardiff.ac.uk/scmne/flask-labs/-/tree/part_3.2) |
| 4.0 | Blogging Website: deployment on OpenShift | [part 4.0](https://git.cardiff.ac.uk/scmne/flask-labs/-/tree/part_4.0) |
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Initial Project Setup Required:
## Add your files
- activation of virtual environment (see the lab instructions)
- installation of the necessary project dependencies
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
### Project Dependencies:
* to install a particular library:
```
cd existing_repo
git remote add origin https://git.cardiff.ac.uk/c22090044/cmt313_week5.git
git branch -M main
git push -uf origin main
pip install <LIBRARY>
```
&nbsp;&nbsp;&nbsp; e.g.: ``` pip install flask ```
## Integrate with your tools
- [ ] [Set up project integrations](https://git.cardiff.ac.uk/c22090044/cmt313_week5/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
* to install all dependencies recursively from ```requirements.txt``` file:
```sh
pip install -r requirements.txt
```
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
* to see all installed dependencies in the console:
```console
pip freeze
```
## License
For open source projects, say how it is licensed.
* to save the project dependencies in ```requirements.txt``` file:
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
```console
pip freeze > requirements.txt
```
%% Cell type:code id: tags:
``` python
import pandas as pd
```
%% Cell type:code id: tags:
``` python
df=pd.read_csv('Meteorite_Landings.csv')
df.head()
```
%% Output
name id nametype recclass mass (g) fall year reclat \
0 Aachen 1 Valid L5 21.0 Fell 1880.0 50.77500
1 Aarhus 2 Valid H6 720.0 Fell 1951.0 56.18333
2 Abee 6 Valid EH4 107000.0 Fell 1952.0 54.21667
3 Acapulco 10 Valid Acapulcoite 1914.0 Fell 1976.0 16.88333
4 Achiras 370 Valid L6 780.0 Fell 1902.0 -33.16667
reclong GeoLocation
0 6.08333 (50.775, 6.08333)
1 10.23333 (56.18333, 10.23333)
2 -113.00000 (54.21667, -113.0)
3 -99.90000 (16.88333, -99.9)
4 -64.95000 (-33.16667, -64.95)
%% Cell type:code id: tags:
``` python
df.nlargest(20, 'mass (g)')
```
%% Output
name id nametype recclass mass (g) fall \
16392 Hoba 11890 Valid Iron, IVB 60000000.0 Found
5373 Cape York 5262 Valid Iron, IIIAB 58200000.0 Found
5365 Campo del Cielo 5247 Valid Iron, IAB-MG 50000000.0 Found
5370 Canyon Diablo 5257 Valid Iron, IAB-MG 30000000.0 Found
3455 Armanty 2335 Valid Iron, IIIE 28000000.0 Found
12613 Gibeon 10912 Valid Iron, IVA 26000000.0 Found
5468 Chupaderos 5363 Valid Iron, IIIAB 24300000.0 Found
26297 Mundrabilla 16852 Valid Iron, IAB-ung 24000000.0 Found
920 Sikhote-Alin 23593 Valid Iron, IIAB 23000000.0 Fell
5016 Bacubirito 4919 Valid Iron, ungrouped 22000000.0 Found
22921 Mbosi 15456 Valid Iron, ungrouped 16000000.0 Found
38317 Willamette 24269 Valid Iron, IIIAB 15500000.0 Found
26174 Morito 16745 Valid Iron, IIIAB 10100000.0 Found
26338 Nantan 16906 Valid Iron, IAB-MG 9500000.0 Found
5613 Cranbourne 5463 Valid Iron, IAB-MG 8600000.0 Found
36882 Santa Catharina 23162 Valid Iron, IAB-ung 7000000.0 Found
5083 Bendegó 5015 Valid Iron, IC 5360000.0 Found
5201 Brenham 5136 Valid Pallasite, PMG-an 4300000.0 Found
419 Jilin 12171 Valid H5 4000000.0 Fell
38206 Vaca Muerta 24142 Valid Mesosiderite-A1 3828000.0 Found
year reclat reclong GeoLocation
16392 1920.0 -19.58333 17.91667 (-19.58333, 17.91667)
5373 1818.0 76.13333 -64.93333 (76.13333, -64.93333)
5365 1575.0 -27.46667 -60.58333 (-27.46667, -60.58333)
5370 1891.0 35.05000 -111.03333 (35.05, -111.03333)
3455 1898.0 47.00000 88.00000 (47.0, 88.0)
12613 1836.0 -25.50000 18.00000 (-25.5, 18.0)
5468 1852.0 27.00000 -105.10000 (27.0, -105.1)
26297 1911.0 -30.78333 127.55000 (-30.78333, 127.55)
920 1947.0 46.16000 134.65333 (46.16, 134.65333)
5016 1863.0 26.20000 -107.83333 (26.2, -107.83333)
22921 1930.0 -9.11667 33.06667 (-9.11667, 33.06667)
38317 1902.0 45.36667 -122.58333 (45.36667, -122.58333)
26174 1600.0 27.05000 -105.43333 (27.05, -105.43333)
26338 1958.0 25.10000 107.70000 (25.1, 107.7)
5613 1854.0 -38.10000 145.30000 (-38.1, 145.3)
36882 1875.0 -26.21667 -48.60000 (-26.21667, -48.6)
5083 1784.0 -10.11667 -39.20000 (-10.11667, -39.2)
5201 1882.0 37.58250 -99.16361 (37.5825, -99.16361)
419 1976.0 44.05000 126.16667 (44.05, 126.16667)
38206 1861.0 -25.75000 -70.50000 (-25.75, -70.5)
%% Cell type:code id: tags:
``` python
def inputmeteor():
name = input("Enter the name of the meteor: ")
mass = input("Enter the mass of the meteor: ")
year = input("Enter the year of the meteor: ")
id = input("Enter the id of the meteor: ")
recclass = input("Enter the recclass of the meteor: ")
reclat = input("Enter the reclat of the meteor: ")
reclong = input("Enter the reclong of the meteor: ")
geolocation = input("Enter the geolocation of the meteor: ")
fall = input("Enter the fall of the meteor(Fell/Found): ")
newmeteor= dict(name=name,id=id,recclass=recclass,mass=mass,fall=fall,year=year,reclat=reclat,reclong=reclong,geolocation=geolocation)
return newmeteor
```
%% Cell type:code id: tags:
``` python
new_row = inputmeteor()
df = df.append(new_row, ignore_index=True)
df.to_csv("Meteorite_Landings.csv", index=False)
```
Hello, yintao!
\ No newline at end of file
uierubvfujbs
My name is shit
My name is Ziyan Lu
Try an Error line
hvbfhybvusjbdjsbjdsk
jhdvbfudbuvbabjebjka
\ No newline at end of file
def Sum(n,i, sum = 0):
if i > n:
return sum
else:
sum += i
return Sum(n, i+1, sum)
print(Sum(100,1))
def merge(list1, list2):
list = []
i = 0
j = 0
while(len(list1) > i and len(list2) > j):
list.append(list1[i])
i+=1
list.append(list2[j])
j+=1
if (len(list1) > len(list2)):
list.extend(list1[i:])
else:
list.extend(list2[j:])
return list
print(merge([1,2,3,4],['a','b','c',2,9]))
def first_n_fibonacci(n):
fib = [0, 1]
for i in range(2, n):
fib.append(fib[i-1] + fib[i-2])
return fib
print(first_n_fibonacci(100))
dsddssd
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment